11-20-2015, 01:44 AM
(This post was last modified: 11-20-2015, 01:48 AM by PureTryOut.)
Hey all.
I'm new to Lua, but I'm trying to create and access a sqlite3 database.
I managed to create a database using the following:
Now this seems to work fine, a database is created in the plugin folder. However according to the sqlite tool on Linux, it's empty.
Could anybody write a quick tutorial on how to do this? Preferably with prepared statements. Simply inserting data in a database, and afterwards selecting it and putting it into a variable and/or array.
Thanks in advance!
I'm new to Lua, but I'm trying to create and access a sqlite3 database.
I managed to create a database using the following:
db = sqlite3.open(PLUGIN:GetLocalFolder() .. "/database.sqlite3")
-- Create tables and insert default records
stmt = db:prepare("CREATE TABLE test (name, address)")
stmt:step()
stmt:finalize()
stmt = db:prepare("INSERT INTO test (name, address) VALUES ('John Doe', 'Test street 3')")
stmt:step()
stmt:finalize()
db:close()
Now this seems to work fine, a database is created in the plugin folder. However according to the sqlite tool on Linux, it's empty.
Could anybody write a quick tutorial on how to do this? Preferably with prepared statements. Simply inserting data in a database, and afterwards selecting it and putting it into a variable and/or array.
Thanks in advance!

