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

Flat file database (*)

Started by PrinzJuliano, 09 May 2013 - 12:01 PM
PrinzJuliano #1
Posted 09 May 2013 - 02:01 PM
Hi guys, i started to create a simple database system:

Functions:
SpoilerloadDatabase(filename) : returns a 2 Dimesional table
createDatabase(table,filename) : creates/overrides the <filename> an puts the whole content of table in

This database is simple for having a 2d array save,

Will be added soon:
Spoiler-encryption,

Here is the pastbin link:
http://pastebin.com/YnWmFmTm

In computer:

pastebin get YnWmFmTm

API:

os.loadAPI("database")

example = {
[1] = {"r1 c1","r1 c2","r1 c3"},
[2] = {"r2 c1","r2 c2","r2 c3", "r2 c4"},
[3] = {"r3 c1","r3 c2","r3 c3","r3 c4","r3 c5"}
}

database.createDatabase(example,"example.db")
new = database.loadDatabase("example.db")
--in new is now the complete code from "example.db" in array form

superaxander #2
Posted 09 May 2013 - 02:14 PM
nice
Alerith #3
Posted 11 May 2013 - 11:33 AM
Great, i will download it. Thank you :D/>