Hi,
I have a problem with sql.
I’m trying to do is create a database and insert a perform conditional content. But “seems” that saves data so run a print to see what is stored and displayed on the console “nil”
This is the code:
[lua]
require “sqlite3”
– MAKE LOAD DDBB
local path = system.pathForFile(“dattalives.db”, system.DocumentsDirectory)
db = sqlite3.open( path )
local function onSystemEvent( event )
if( event.type == “applicationExit” ) then
db:close()
end
end
–MAKE TABLES
local tablesetup = [[CREATE TABLE IF NOT EXISTS base1 (id INTEGER PRIMARY KEY, valuebase1);]]
print(tablesetup)
db:exec( tablesetup )
tablesetup = [[CREATE TABLE IF NOT EXISTS base2 (id INTEGER PRIMARY KEY, valuebase2);]]
print(tablesetup)
db:exec( tablesetup )
valuebase1 = 2
valuebase2 = 2
tablesetup =[[INSERT INTO base1 VALUES (NULL, ‘]]…valuebase1…[[’);]]
db:exec( tablesetup )
tablesetup =[[INSERT INTO base2 VALUES (NULL, ‘]]…valuebase2…[[’);]]
db:exec( tablesetup )
–QUERY
for row in db:nrows(“SELECT valuebase2 FROM base2”) do
if valuebase2 == 2 then
print(“OK”)
else
print(“no OK”)
end
– I do not see as a result, I make a print to check that everything is OK
print(valuebase2) --I get nil value in console
end
[/lua]
from already thank you very much! [import]uid: 192093 topic_id: 36371 reply_id: 336371[/import]