Im trying to understand how to INSERT INTO and SELECT FROM a field from my table. Not sure what the problem is.
First I build the database
require("sqlite3")
--Open data.db. If the file doesn't exist it will be created
local path = system.pathForFile("data.db", system.DocumentsDirectory)
db = sqlite3.open( path )
Set up my table
local tablesetup = "CREATE TABLE IF NOT EXISTS LEVEL\_INFO (LEVEL\_ID INTEGER PRIMARY KEY, HIGHSCORE INTEGER, LEVEL\_STATUS INTEGER, TROPHEY INTEGER)"
db:exec( tablesetup )
Then try to insert data into a field (syntax?)
local testvalue = 99999
local tablefill ="INSERT INTO LEVEL\_INFO(HIGH\_SCORE) WHERE LEVEL\_ID = '1' VALUES (NULL, '"..testvalue.."')"
db:exec( tablefill )
And later try to read the field from another lua file by…
local db = sqlite3.open\_memory()
local highScoredata = "SELECT FROM LEVEL\_INFO(HIGH\_SCORE) WHERE LEVEL\_ID = '1'"
local highScore = db:exec( highScoredata )
print(highScore .. " highsScore")
[import]uid: 28912 topic_id: 8610 reply_id: 308610[/import]