You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DizzasTeR edited this page Nov 9, 2020
·
1 revision
SQLiteDatabase
exec
Executes a sqlite query
int SQLiteDatabase:exec(string query [, ...optionalParameters])
Parameters
string query — The query to execute
optional optionalParameters — Forward any extra parameters with the query (Used for prepared statements)
Returns
int - Return code
Example #1
localdb=SQLite.openDatabase("test.db")
ifdb:tableExists("Test") thenlocalr=db:exec("DROP TABLE Test")
iprint("Dropped Table: Test", r)
endifnotdb:tableExists("Test") thenr=db:exec("CREATE TABLE Test(id INTEGER, name TEXT)")
iprint("Exec #1", r)
endlocalresult=db:exec("INSERT INTO Test VALUES (1, 'dizz'), (2, 'xmomo'), (3, 'slc')")
iprint("Exec #2", result)
result=db:query("SELECT * FROM Test WHERE id = ? OR name = :genius OR name = ?", {3, [":genius"] ='dizz', [3] ='xmomo'}) -- The string based bind acts as [2] so for the last ? the bind slot should be 3iprint("Query #1", result)
SQLite.closeDatabase(db)