Server communication with database - database

I'm creating an online game and the client is going to be made using unity as well as the server and I'm wondering whether it's okay for the server to communicate with mysql database via PHP

For simple tasks, there is actually nothing wrong with that.
There is also a example of using this method in the wiki here: http://wiki.unity3d.com/index.php?title=Server_Side_Highscores
But be aware: that is not the fastest solution.
You could make a faster direct connection with a plugin like this one:
https://github.com/Hanslen/Unity-with-MYSQL
And for native unity support on Android and iOS support i would go with a sqlite database plugin: https://github.com/rizasif/sqlite-unity-plugin

Related

Are there any code samples for Uno platform accessing MSSQL, PostgreSQL or MYSQL?

I have tried various ways to connect to different DB engines (asynchronously), but they all failed when I deployed the code and executed it via my browser in WASM format. The code worked well for UWP tho, so I'm a bit baffled.
Although there's a sample for SQLLite in browser, it wasn't too helpful for me. Hopefully someone could give me a few pointers to continue. Thanks in advance
The support for SQLite is about running the database inside of the browser itself, but not about running it from a remote database.
If you need to have such a support, you will need to have a .NET SQL provider that supports plain HTTP/S or WebSockets, which is available for cloud-based databases.
In general though, you may want to consider a WebAssembly app as a mobile app for which it is best to access remote resources like databases through a Web API.
Note that the Chrome developers have in mind the creation of a RAW sockets API, which would enable TCP non-HTTP connections to be created.

React Native - connect to PostgreSQL database

I would like to connect with React Native to an external database, like PostgreSQL, MySQL or what ever. Is this possible?
But first let me tell you something about my plan:
I will develop my application for multiple installations (multiple devices - one installation on one device). All devices are connected with a local network which is provided by a Windows installation (server). On the server runs a database (PostgreSQL) and I would like to connect to this database with all my devices.
The server (or in fact its database) should store tasks and each device should access to these tasks (read and write) locally.
I had also some other ideas like simple SMB-XML file storage (but the problem with collisions) and an SQLite database on an SMB shared file - but the website of SQLite tells that this will not avoid problems with multiple accesses. Therefore I need another local solution. This brought me to provide a database which is accessible from the local network.
I would be very grateful if someone has a note how to solve this problem.
Thank you!
In order to access a database directly from react native you would need a pure JavaScript database driver. A quick google search produced a JavaScript drivers for PostgreSQL (https://github.com/brianc/node-postgres) but it is written for Node.js and I doubt it will work in JavaScript Core or Chrome. CouchDB works via a REST API and it's actually intended for direct access by multiple clients. There are multiple JavaScript clients available for that.
BUT why do you want your clients to connect to the DB directly? What you describe seems like a pretty standard application model. You'll just need a backend running on your server talking to the DB and providing an API. Good old web development. If you want to write JavaScript on the backend I suggest using Node.js
If you really can't or don't want to write a backend, there are several services that provide API for data storage and even some data processing. But of course they aren't local. Have a look at parse.com or firebase.com for example.

Any node.js relational database bindings for Windows?

I'm trying to build a RESTful internal web server at work using node.js, where I'm currently restricted to using a Windows 2003 Server.
I've hit a stumbling block with regards to database support however. Are there any bindings currently available for reading and writing to sqlite, PostgreSQL or MySQL on Windows based machines?
Mariano has mentioned Windows support in the future in these comments, but ideally I'd like to use something available just now as a proof of concept.
I'm author of mysql-native.
Both official (felixge node-mysql) and my driver has been successfully used under windows,
I'm using and developing it under linux/windows 50/50% time . Feel free to contact me if you have any questions
Have you tried mysql-native? It's native (mysql) which means there are no other dependencies, so should run on any platform node supports. Seems to be actively maintained also, and has some examples to show you how to use the library. Link: https://github.com/sidorares/nodejs-mysql-native

Query SQL Server Database from native iOS Application

I am working on an in-house, iOS app that will need read-only access to a SQL Server with multiple databases. I know the stock answer here is "write some web services", but I'd like a solution that is self-contained. Is there any way to directly connect to a SQL Server database from an iOS application? I'm thinking something like a basic ODBC connection.
I've seen a lot of users asking this question, but very few answers other than "write a web service." Is that really the only way?
A web service is indeed the only way, but Red Gate's written one you can reuse:
http://www.mobilefoo.com/iSqlServerSDK.html
http://labs.red-gate.com/Tools/Details/iSqlSDK
It's not officially released yet, just in beta, so keep in mind that features & prices may change.
Actually the easiest way is to create a MVC 3 or 4 asp.net web application. call the web methods. You don't need any API to pay for.
I use SBJson to serialize domain object and then send the objects as serialized jSOn to MVC 3. It's super easy to do. I even send images with base64, so it's .net compatible.
See my blog post with sample code:
http://nickturner.wordpress.com/2012/10/09/107/
So, after much searching and trial and error, unfortunately the best (only?) way I've found is indeed using Web Services.
Fortunately, Linq to SQL makes the WCF-creation-side incredibly easy. Once I got someone at work to walk me through setting up a Windows web server and adding the web service (and buying access to an online web server), the Windows side was up and ready to go.
I'm still working through all of the syntax stuff on the SOAP interaction side, but keeping my different methods somewhat similar in structure allows me to tinker a little until it works. By this time, I think I've gotten it to work pretty well.
So, both answers I got back were (disappointingly) correct. The only way to interact is through a Web Service. Even the 3rd party solutions they mentioned were really just convenient wrappers around the same type of technology. As it turns out, I'd rather have finer control over the process.
One word of advice: Get a real, external web server. I tried doing this on a non-Server Windows VM on my iMac/MacBook Pro, and it was like pulling teeth! Once I actually got access to an external, full, stand-alone web server, the process was much more streamlined and easy. Do yourself a favor and take that headache out of the equation!
There was a SQL ISAPI extension as part of SQLXML, but I think it has been deprecated: http://msdn.microsoft.com/en-us/library/aa226559%28v=SQL.80%29.aspx
This was effectively a pre-built, and relatively open, web service - so I'm not sure this counts as a direct connection.
You could also check out http://odbcrouter.com/Main

nodejs and database communication - how?

I've heard much good about nodejs and writting client-server application with it. But I can't get, for example, when developing IM client-server application, how nodejs server script is supposed to talk to database server to actually store it's data? Or may be I miss something and nodejs server scripts are not supposed to do that? If so, please, push me to correct direction.
I've noticed DBSLayer http://code.nytimes.com/projects/dbslayer/wiki, but it looks like it's still in beta.
You need to grab a module that handles the communication to the database you want. See here for a list of modules for node.js. Popular databases that work well with node.js are MongoDB, CouchDB and Redis.
As stagas says, you can use a module that handles communication if you want to use an external database.
If you want an internal (=embedded) database, you can use one written in javascript you can require like any other module such as NeDB or nStore. They are easier to use and useful if your webapp doesn't need to handle a lot of concurrent connections (e.g. a tool you make for yourself or a small team), or if you write a desktop app using Node Webkit

Resources