Populating a sql database with a lua table

Not sure if anyone has done this before but here’s something I came up with today.

local Attributes = { "Strength", "Intelligence", "Dexterity", "Stamina" } //setup attributes

sql.Query("CREATE TABLE IF NOT EXISTS AndrewRPG_Attributes('steam' TEXT NOT NULL, '" .. table.concat(Attributes, "' INTEGER NOT NULL, '") .. "' INTEGER NOT NULL, PRIMARY KEY('steam'));") //table Holding Atrribute Levels

Basically you can put whatever you want into the lua table and when the query is run it will populate the sql database, every once in awhile i come up with something useful i like to think =P

Andrew (enjia2000 on steam)

You haven’t even connected to a db.

He does not need to connect. Why are all users of facepunch so slow? THERE IS SQLite MODULE IN GMOD! You DO NOT need to connect anywhere. You just do queries to endine that stores database in local file.

Look at my tutorial :wink:


You’re tutorial says nothing about storing dynamically formatted tables.