lua:db:exec
This is an old revision of the document!
db.exec( statement )
Execute sql statement.
If statement is a query, return value is a table with the query results.
Check if a table exists:
if #db.exec[[SELECT name FROM sqlite_master WHERE type='table' AND name='grraka_animals']] <1 then -- table doesn't exist, do something here end
Insert values into table:
db.exec[[INSERT INTO grraka_animals( animal_name, location ) VALUES( 'Dog', 'land')]]
Create a table:
db.exec[[CREATE TABLE grraka_animals( animal_name TEXT, location TEXT)]]
Run a query and process the results:
local result=[[SELECT animal_name, location FROM grraka_animals ORDER BY animal_name]] for _,row in result do say(row.animal_name.." lives in "..row.location) end
lua/db/exec.1454907672.txt.gz · Last modified: 2016/02/08 05:01 by vodur