Trouble inserting data into an sqlite3 database
#1
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:
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!
Reply
Thanks given by:


Messages In This Thread
Trouble inserting data into an sqlite3 database - by PureTryOut - 11-20-2015, 01:44 AM



Users browsing this thread: 5 Guest(s)