MySQL?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Freze
Prole
Posts: 9
Joined: Wed Apr 13, 2011 1:15 pm

Re: MySQL?

Post by Freze »

I'm just trying LOVE out. Because, I've had nothing else to do. It's basically just a fun experiment. I'm used to other forms of lua.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: MySQL?

Post by kikito »

Freze wrote:I'm just trying LOVE out. Because, I've had nothing else to do. It's basically just a fun experiment. I'm used to other forms of lua.
Well in that case I see two options:
  • You can use luasocket (it is not in the docs, but LÖVE includes it on the last stable version) to communicate with a mysql server. You can then setup a web-based server on your database server, using something like phprestsql or dbslayer. But in essence this would mean that you would not be speaking with mysql, but with a web service. Once you have a web service, it's usually simpler to access "higher-level" stuff than the raw tables.
  • You can include the binary module of LuaSQL in a LÖVE game. However, that lib is platform-dependant. This means that you will either have to maintain three different versions of your LÖVE (win+mac+linux), or ditch platform independency and develop only for one platform (i.e. win).
I don't want to sound discoraging, but it looks like there's no easy option. Every option I can think of has its drawbacks.

If I were you, I'd think about the possibility of using a simple web service instead of sql databases.
Last edited by kikito on Mon Apr 25, 2011 12:02 pm, edited 1 time in total.
When I write def I mean function.
Freze
Prole
Posts: 9
Joined: Wed Apr 13, 2011 1:15 pm

Re: MySQL?

Post by Freze »

Alright, thanks.
User avatar
Ethnar
Prole
Posts: 7
Joined: Sat Nov 15, 2008 7:07 pm
Location: Poland
Contact:

Re: MySQL?

Post by Ethnar »

Forgive me using this month old topic, but I don't think it'd be any good to start new one since what I'm about to ask strictly relates to the stuff written here (and plus I don't think much attention would be needed for SQL using LOVE, for reasons already mentioned in this thread).

So I'd like to use LOVE with access to mysql database. From all I've read here I concluded that the easiest would be to use LuaSQL.
I must admit I'm pretty green when it comes to lua, includes, libs etc. and all I needed so far was LOVE and LUBE.
I'm just working on little proof of concept and I just hope to mash up something real quick, so far LOVE was an absolute charm. I don't need it cross-platform, I just hope to have it running on my Win7 machine.

So, I've downloaded this package: http://luaforge.net/frs/download.php/26 ... -lua51.zip
That contains 2 dlls. I tried to put them in LOVE and in my project folder (where main.lua is), preserving the /luasql/ folder and structure. From there I tried to include that lib in every way I could find to no avail. The closest I got is probably

Code: Select all

require 'luasql.mysql'
But it throws error as if it couldn't find the file:

Code: Select all

Error: error loading module 'luasql.mysql' from file '.\luasql\mysql.dll':
	The specified module could not be found.


stack traceback:
	[C]: ?
	[C]: in function 'require'
	[string "main.lua"]:22: in main chunk
	[C]: in function 'require'
	[string "boot.lua"]:1: in function <[string "boot.lua"]:1>
	[C]: in function 'xpcall'
When I placed empty file mysql.lua in /luasql/ folder it managed to load it just fine and carried on executing the rest of the code, so I figure it's not a matter of path.
I also tried

Code: Select all

package.loadlib('luasql.mysql', 'init')
it throws no error, but I can't seem to use anything from the lib (everything is a nil) and I have high doubt I provided correct 2nd argument anyway.

On LuaSQL, on the examples page I found the example use for Mysql driver at the very bottom: http://www.keplerproject.org/luasql/examples.html
Seems like the solution I included here, but alas, the error I'm getting.

I'm using LOVE version 0.7.2 and checking with _VERSION I get Lua 5.1, so all should be good when it comes to version compatibility.

Please, help me and point out that [most likely very stupid] mistake I'm doing here.

EDIT:
I believe I've found a solution. After playing a bit with cpath, I managed to get an error that lua5.1dll was missing when I tried to include the lib with

Code: Select all

require 'luasql.mysql'
So I installed lua5.1 for win and copied the lua5.1.dll to my app folder. After doing so, there were no errors starting up the application and i can successfully execute code

Code: Select all

env = assert (luasql.mysql())
which leads me to believe I actually have the lib running in my app. :)

Leaving this info here, perhaps someone will find it useful. :)
JosepM
Prole
Posts: 2
Joined: Wed Jun 12, 2019 6:37 am

Re: MySQL?

Post by JosepM »

Hi,

I read the entire post about connecting to a mySQL, what about use an API REST service? I plan read data to update at the end of each turn game.
I found this https://love2d.org/forums/viewtopic.php?t=83322
Any experience using?

Salut,
Josep M
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 3 guests