MySQL

Hey,

i wonder if its possible to get data from and into a MySQL database which is hosted on a server.
(I can access the database via phpMyAdmin and with php scripts on websites. )

Anyone here who did something like this already?

I don’t think you can do so directly at the moment, but If you manage to expose the data via an API endpoint (which needs to adhere to JSON syntax) on the server, you should be able to use the http.request function followed by json.decode .

Unfortunately I am not a huge fan of PHP, so I cannot help you there, but a quick Google search should yield results as to what to do on the server side.

that sounds complicated :sweat:

Edit: just found LuaSQL
https://keplerproject.github.io/luasql/index.html
Maybe this can work with devold. I will read more about it tomorrow :slight_smile:

It’s a C extension to Lua. It could most likely be converted to a Defold extension.

BUT do you really want the client to directly update the database? What about security? I’m assuming the database is password protected. You’d have to include the user and password in the client and that’s like handing the keys to the vault to a bunch of bank robbers.

What you want is a webserver that takes care of user authentication, data validation and database updates. For instance some PHP scripts.

What kind of data would you like to store? You could perhaps use something like PlayFab or an AWS service instead of rolling your own backend solution.

3 Likes

I am thinking about a calendar for multiple persons.

I will take a second look at Playfab. Thanks for these hints.

Just grab some PHP framework if you want to simplify your life and create a simple REST API to get and set data from mysql. https://laravel.com/ is a very good place to start, it’s very simple to understand and really fast to develop. Free video tutorial is also available here https://laracasts.com/series/laravel-from-scratch-2017.

1 Like

Yes, hiding/abstracting away MySQL as much as possible is a good idea. Reminds me of this blog post I read the other day: http://blog.cleancoder.com/uncle-bob/2017/12/03/BobbyTables.html

I guess this stuff is a bit to high for me^^

Look at Google firebase, @britzl we should make a native extension for that btw. Basically only a “remote_table.lua” which maps to firebase storage

DeFire (pattent pending) :laughing:

4 Likes

Thank you for the hint. Firebase looks nice, because i can use it free with my usecase :slight_smile:

Are there any extensions i can use in defold or do i have to figue out how to include the firebase sdk into defold my selfe?

There is currently no extension in the Asset Portal. You need to figure out how to bind the extension to Defold.

1 Like

I guess i have to take the C++ Sdk (https://firebase.google.com/docs/cpp/setup) and include it anyhow into defold.

But how can i keep the sdk up to date?

Edit: Nevermind, just realised i have to write everything on my own.

I think that you can use a lua module like this if you want to use firebase with defold.

Tryed that now for hours -_-

The module uses Lua Http (https://github.com/daurnimator/lua-http) which i cant install with all its dependencies.
Also took a look at LuaSocket from the asset portal but i dont understand what i have to do there :frowning: