This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
DannySMc's profile picture

ComputerCraft and MySQL or some kind of database

Started by DannySMc, 22 September 2014 - 02:39 PM
DannySMc #1
Posted 22 September 2014 - 04:39 PM
Okay, so I do a lot of web design but this confuses me, how do you use an online database, like MySQL or PHP myAdmin to use with ComputerCraft?

I need to store just some simple data….
+ Username
+ Password
+ DateOfBirth
+ Currency
+ Rank
+ PermissionLevel
+ Nickname
and more etc

How could I post these to an online web server and easily edit it? without having to constantly download it and update it? is there a way, i can use (using the sql is an api): sql.insertString("Username1", "dbUSERS")
and use it the exact same as a table in lua, with table.insert etc or even the same ideas just different names? with use of an api? I don't mind just need help on how to make it. or some information on what I am aiming for?
thanks
SquidDev #2
Posted 24 September 2014 - 10:21 AM
You have several options:

Use ccDB
I haven't used this myself but I'm pretty sure you would be able to interface with your database… It is a mod though so won't work on a server unless it is installed.

Some sort of API
If you have a database I presume you have a web server. Your best bet may be to create some sort of API to interface with it. What you don't want to enable though is people to execute raw SQl with it, so something like: http://example.com/api/users/create/?name=foo&password=bar

Watch out for SQL injections though!

Does it have to be online?
It might be better just to recreate this entirely in CC - you have a DB computer and everything interfaces with that. Ask yourself if this is the best option first.

I don't know if any of those appeal to you but CC isn't really designed for this sort of stuff.
DannySMc #3
Posted 27 September 2014 - 04:59 PM
You have several options:

Use ccDB
I haven't used this myself but I'm pretty sure you would be able to interface with your database… It is a mod though so won't work on a server unless it is installed.

Some sort of API
If you have a database I presume you have a web server. Your best bet may be to create some sort of API to interface with it. What you don't want to enable though is people to execute raw SQl with it, so something like: http://example.com/a...oo&password=bar

Watch out for SQL injections though!

Does it have to be online?
It might be better just to recreate this entirely in CC - you have a DB computer and everything interfaces with that. Ask yourself if this is the best option first.

I don't know if any of those appeal to you but CC isn't really designed for this sort of stuff.

Well it has to be online as we are running over 8 servers and they need to be linked, so you can login on all of them. Also I shall have a look, thanks for the help, and also yes I know SQL can have security precautions but the code will automatically check for certain things.