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

Database API

Started by _removed, 04 February 2015 - 05:47 PM
_removed #1
Posted 04 February 2015 - 06:47 PM
I was bored and had nothing to do so I made a database API. Currently, it only has 3 functions. The functions are:

addUser(user)
setPath(path)
retreiveUsers()

This is how you would use the API:


os.loadAPI("databaseAPI") -- The name of the API

databaseAPI.setPath("path") -- Sets the path of where the users will be, by default it will be "users"
databaseAPI.addUser("user") -- Adds a user to the table

for k, v in ipairs(databaseAPI.retreiveUsers()) do --Uses ipairs so it is in order and needs to be in a loop
  print(v)
end

pastebin get nQL5QBGX databaseAPI
Edited on 04 February 2015 - 05:47 PM
Lignum #2
Posted 04 February 2015 - 07:05 PM
Um, this is just a glorified textutils.serialise.
Also, your example outputs this error: database:20: attempt to index ? (a nil value)
_removed #3
Posted 04 February 2015 - 07:12 PM
Um, this is just a glorified textutils.serialise.
Also, your example outputs this error: database:20: attempt to index ? (a nil value)
Thanks a lot!
I'll patch it tomorrow.
SpencerBeige #4
Posted 05 February 2015 - 01:27 AM
wow, i look for apis, and the first one i see is by u, gratz smigger ;p