I’m having the worst time getting this to work. What am I doing wrong? This appears to work until I try and read the table with nrows() at which point I get the error: No such table: words. The two previous results print 1, which I’m assuming means they executed successfully. I see data.db in the project Documents folder, but it’s empty.
local table_name = “words”
local sqlite = require( “sqlite3” )
local path = system.pathForFile( “data.db”, system.DocumentsDirectory )
local db = sqlite3.open( path )
local results = db:exec( [[CREATE TABLE IF NOT EXISTS]]…table_name…[[
(id INTEGER PRIMARY KEY autoincrement, word, solved, index ); ]] )
print( “Create table results:”, results )
results = db:exec( "INSERT INTO "…table_name…“VALUES (NULL, ‘HELLO’, ‘false’, ‘1’ )” )
print( “Insert row results:”, results )
for row in db:nrows( "SELECT * FROM " … table_name ) do
print( row.word )
end