A few questions on dbmysql vs SQLite

BlitzMax Forums/Brucey's Modules/A few questions on dbmysql vs SQLite

Sokurah(Posted 2010) [#1]
Phew, I finally managed to get the dbmysql module to build. Yay.

But I was hoping for something that was DLL-free which I now see it isn't.

I use Windows but I'd like at some point to offer my games (currently with online scores using ETNA) on OSX as well so I'd think I need something that doesn't require DLL's?

What do more bright people than me do in this case? ;-)

...oh, and what's the difference between dbmysql vs SQLite?

Thanks.


xlsior(Posted 2010) [#2]
SQLite is an entirely different database flavor from MySQL -- both are based on the SQL language, but SQLite is more feature-limited.

It's great for 'simple' databases, though: one major advantage of SQLite is that you can have your database stored in a single file that you put in the same folder as your executable. It doesn't actually need any complex database services running, with SQLite your program can run database queries directly against that file.

SQLite is mainly intended for relatively small, simple databases. MySQL can deal with huge databases that are a lot more complicated.


xlsior(Posted 2010) [#3]
Oh, something else: using direct database access to keep highscores may or may not work for you, since most hosting providers don't permit direct access to the SQL server from the outside world, but require the requests to come from one of their own webserver IP's.

Those that do allow direct SQL often won't allow it from every IP on the planet, but only from pre-authorized IP addresses, since it's such a huge potential vulnerability to allow those kind of requests from everywhere.

(e.g. allowing it would make it a lot easier for hackers to break into a hosted website's customer or creditcard database)


DavidDC(Posted 2010) [#4]
SQLite is an embedded database that doesn't handle multiple open connections (esp db writes) nearly as well as something like mySQL. But SQLite is just that - light and simple with little overhead dependency wise. It can be very fast too - as it supports a RAM-based database.


Sokurah(Posted 2010) [#5]
using direct database access to keep highscores may or may not work for you, since most hosting providers don't permit direct access to the SQL server from the outside world, but require the requests to come from one of their own webserver IP's.


Oh, I see. I hadn't considered that. That's luckily not an issue (as far as I can tell) when using ETNA since access is done through a PHP script.

Thanks for your answers and for making me aware of the problem.

Edit: I've just checked with my webhost and learned that with my current solution I can only give direct access to the database from 10 predefined IP addresses. Bummer.

However, I can't be the first one who's run into this...is there a way to get mysql access through PHP - cross-platform and no DLL's required?


xlsior(Posted 2010) [#6]
However, I can't be the first one who's run into this...is there a way to get mysql access through PHP - cross-platform and no DLL's required?


Yes.

PHP can interface directly with MySQL, you can create PHP pages that perform the necessary database operations.

These are then hosted with a (commercial) hosting company.

Your program can access the PHP pages directly over http, and pass parameters that will tell the PHP page what to do.

(You should work out some sanity-checking though, to have the PHP page verify that the input is valid and does indeed come from your program. You wouldn't want people to manually submit highscores through a browser)


Htbaa(Posted 2010) [#7]
You could create a REST or RPC service for this. Which seems better and safer to me than direct access to a database.


DavidDC(Posted 2010) [#8]
Do you have any example code to go with your rest.mod Htbaa? It doesn't need to run (ie no need for ssl cert bundle), just to get a feel for the interface.


Htbaa(Posted 2010) [#9]
Ehm yes, rackspacecloudfiles.mod uses it.

It be cool if the module were to be extended to support content handlers to handle XML or JSON. Currently it just returns the content as a String. So when a REST service returns JSON or XML you need to parse the content yourself. I think the composite design pattern comes in handy for this.

But I haven't had any need for it, yet :-).

Just remember you need bah.libcurlssl as a dependency. Or modify rest.mod to work with bah.libcurl if you don't need SSL support.

Update: The module is documented as well, here a copy&paste from the introduction example

SuperStrict
Local request:TRESTRequest = New TRESTRequest
request.AddHeader("X-API-Key", "KD93DJ03LW20")

Local headers:String[] = ["username: Htbaa"]
Local response:TRESTResponse = request.Call("http://localhost/rest/account/new", headers, "PUT")
Print "Returned HTTP Status code from REST server is: " + response.responseCode
Print "Some header returned from REST server is: " + response.GetHeader("secret-message")



DavidDC(Posted 2010) [#10]
Ah right, thanks! Sorry, totally missed the intro.bbdoc file.