Page 1 of 3

MySQL?

Posted: Thu Apr 14, 2011 4:17 pm
by Freze
Any way to connect a MySQL Server to the program?
A module or something?

mysql.connect(host, user, pass, database, port) and
mysql.query(query)

Anything like that?
Thanks :)

Re: MySQL?

Posted: Thu Apr 14, 2011 5:10 pm
by nevon
You could use luaSQL.

Re: MySQL?

Posted: Thu Apr 14, 2011 8:34 pm
by BlackBulletIV
nevon wrote:You could use luaSQL.
Though you would have to add it in to your own copy of the LOVE source files, and then compile your own version. That is, if you wanted to use it with LOVE.

Re: MySQL?

Posted: Thu Apr 14, 2011 11:46 pm
by miko
BlackBulletIV wrote:
nevon wrote:You could use luaSQL.
Though you would have to add it in to your own copy of the LOVE source files, and then compile your own version. That is, if you wanted to use it with LOVE.
Lua can load modules dynamically. So if lua can load a module, then love could do it also. You just need to put your (binary or lua) module within package.cpath/package.path respectively. If you want to distribute your game, then you would need to distribute those libraries as well (and for every platform you intend to support).
But then it would be better to statically compile your own love2d indeed.

BTW, I wish love2d had sqlite compiled in...

Re: MySQL?

Posted: Fri Apr 15, 2011 1:03 am
by ishkabible
yep, it works quite well in fact. i used a profiler library with it too.

Re: MySQL?

Posted: Fri Apr 15, 2011 1:15 am
by BlackBulletIV
miko wrote:
BlackBulletIV wrote:
nevon wrote:You could use luaSQL.
Though you would have to add it in to your own copy of the LOVE source files, and then compile your own version. That is, if you wanted to use it with LOVE.
Lua can load modules dynamically. So if lua can load a module, then love could do it also. You just need to put your (binary or lua) module within package.cpath/package.path respectively. If you want to distribute your game, then you would need to distribute those libraries as well (and for every platform you intend to support).
Oh, well that's cool then.

Re: MySQL?

Posted: Fri Apr 15, 2011 6:02 am
by kikito
I'd try using simple Lua files before attempting to use databases. Lua is flexible enough to express both game logic and game data cleanly.

Re: MySQL?

Posted: Sat Apr 16, 2011 4:26 am
by Taehl
I agree with kikito. Why do you need to use SQL databases? Unless it's something REALLY advanced, you should have no problem expressing your data with Lua tables (they really are amazing, I assure you).

Re: MySQL?

Posted: Sat Apr 16, 2011 9:01 am
by BlackBulletIV
Taehl wrote:I agree with kikito. Why do you need to use SQL databases? Unless it's something REALLY advanced, you should have no problem expressing your data with Lua tables (they really are amazing, I assure you).
I agree. You can store data using Lua table syntax in text files, and bring them back into data by using love.filesystem.read and then loadstring. You could also use loadfile or dofile, but this doesn't work in SELOVE.

Re: MySQL?

Posted: Sun Apr 17, 2011 3:55 am
by schme16
despite the 'keep it simple' attitude thats forming in the comments here, I still think its a great idea to have SQL available to use; Mind you, I use JSON to save my tables and such