I looked all over the internet and I couldn't find a way to connect to an MySql and read/write data from there.
Is that even possible to do in LOVE,Lua ?
If so could somebody send me over the files that needed to do that ?
Thank you all.
How can I connect to MySql ?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: How can I connect to MySql ?
Must be hard to research things without being able to arrange your search query right.
5 seconds in google. http://www.keplerproject.org/luasql/
5 seconds in google. http://www.keplerproject.org/luasql/
Last edited by raidho36 on Mon Jul 29, 2013 5:32 pm, edited 1 time in total.
Re: How can I connect to MySql ?
Why do you have to be such an asshole? He obviously didnt search correctly, but you dont have to be an ass about it. Your comments are not welcoming, and discourging to new users to this forum. I also will request that if i post a topic that you do not respond to it, i dont want your opinions even if they are correct.raidho36 wrote:Must be hard to live without being able to arrange your search query right.
There is also http://love2d.org/forums/viewtopic.php?f=5&t=38486 for using sqlite in love.
Re: How can I connect to MySql ?
This here shows raidho36's muturity, please do not pm.
sorry to de-rail your thead.Sent: Mon Jul 29, 2013 1:37 pm
From: raidho36
To: jasonisop
Not that I'd wanted to help a pussy like you, who would whine over such a minor things rather than trying to comprehend/ask what have you did wrong, or better yet, just take that part easy, or make a comeback. That's what adults do. At least, in my country.
Re: How can I connect to MySql ?

Now THAT is a very helpful and constructive reply. Just why do you think I have sent a PM anyway?
And who's an asshole here, a dude with an attitude or random jerk who mainly came to this thread to bitch about it.
</thisnonsense>
Re: How can I connect to MySql ?
Raidho, no offense or anything and sorry to the OP, but you are being such asshole lately. Just because you want people to figure stuff out on their own, that doesn't mean people will or will not do that. Sometimes you just need to ask someone more experienced to get the right answer, you don't have to be a jackass about it.raidho36 wrote:
Now THAT is a very helpful and constructive reply. Just why do you think I have sent a PM anyway?
And who's an asshole here, a dude with an attitude or random jerk who mainly came to this thread to bitch about it.
</thisnonsense>
Sorry for de-railing the thread.
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
personal page and a raycaster
-
- Party member
- Posts: 712
- Joined: Fri Jun 22, 2012 4:54 pm
- Contact:
Re: How can I connect to MySql ?
@gal050, I use mysql in my game. Full code can be found here:
https://github.com/Germanunkol/trainsported
I use luasql as mentioned before in this thread. For an example implementation, check out the databaseLog.lua file:
https://github.com/Germanunkol/trAInspo ... aseLog.lua
With that said, however, you should first get familiar with working with mysql, if you can't even connect to it. Install it on your PC and then try to create a database. Then use Löve/Lua to connect to it (first with the root password) and modify the tables in the database.
Once all of that works, you should create a new mysql user and then use that one from within the Lua script.
What operating system are you using? If you're using linux, I can help you further. If windows, you'll need to find your own tutorials - there's plenty of them, but I have no idea how to use mysql from command line on windows.
And what do you want to use the database for? Are you writing a server for the game?
If you just want to save a game world or something for a single player game you should not use mysql - otherwise every player will need to install mysql before playing your game, which is not a good idea.
https://github.com/Germanunkol/trainsported
I use luasql as mentioned before in this thread. For an example implementation, check out the databaseLog.lua file:
https://github.com/Germanunkol/trAInspo ... aseLog.lua
With that said, however, you should first get familiar with working with mysql, if you can't even connect to it. Install it on your PC and then try to create a database. Then use Löve/Lua to connect to it (first with the root password) and modify the tables in the database.
Once all of that works, you should create a new mysql user and then use that one from within the Lua script.
What operating system are you using? If you're using linux, I can help you further. If windows, you'll need to find your own tutorials - there's plenty of them, but I have no idea how to use mysql from command line on windows.
And what do you want to use the database for? Are you writing a server for the game?
If you just want to save a game world or something for a single player game you should not use mysql - otherwise every player will need to install mysql before playing your game, which is not a good idea.
trAInsported - Write AI to control your trains
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
Re: How can I connect to MySql ?
MySQL comes with a terminal which makes it extremely convenient. Login, select the database you want (or create one first), then run any query you want.Germanunkol wrote:What operating system are you using? If you're using linux, I can help you further. If windows, you'll need to find your own tutorials - there's plenty of them, but I have no idea how to use mysql from command line on windows.
Re: How can I connect to MySql ?
Thanks to all of you.
I made the database using WampServer, When I load the code it's connecting to the database and finds the table but when I'm trying to take info it's crashing the software.
http://pastebin.com/MSpL8fHr
Thank you all again for the help.
I made the database using WampServer, When I load the code it's connecting to the database and finds the table but when I'm trying to take info it's crashing the software.
http://pastebin.com/MSpL8fHr
Thank you all again for the help.
-
- Party member
- Posts: 712
- Joined: Fri Jun 22, 2012 4:54 pm
- Contact:
Re: How can I connect to MySql ?
Have you figured this out yet?
If not, can you tell us the error message you're getting?
Try without the semicolons after the statements (especially the select), the luasql examples don't do it... and it might mean that you're actually executing two statements, I'm not sure.
Otherwise, you can try this:
(Taken from here (bottom example).
If not, can you tell us the error message you're getting?
Try without the semicolons after the statements (especially the select), the luasql examples don't do it... and it might mean that you're actually executing two statements, I'm not sure.
Otherwise, you can try this:
Code: Select all
function rows (connection, sql_statement)
local cursor = assert (connection:execute (sql_statement))
return function ()
return cursor:fetch()
end
end
--Here is how the iterator is used:
require "luasql.mysql"
env = assert (luasql.mysql())
con = assert (env:connect"my_db")
for id, name, address in rows (con, "select * from contacts") do
print (string.format ("%s: %s", name, address))
end
trAInsported - Write AI to control your trains
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
Who is online
Users browsing this forum: Bing [Bot] and 4 guests