Same happens with me. I’ve tried several way, no success till now:
require "sqlite3"
local path = system.pathForFile( "myDb.sqlite", system.ResourceDirectory )
local db = sqlite3.open(path)
local today = os.date("%x")
local tName = "Alexandre Souza"
local q1 = 'INSERT INTO viewed VALUES ("'..today..',"'..tName..'")'
print(q1) --prints the string correctly
--First try
db:exec[[q1]] --DO NOT EXECUTE anything neither returns an error
--Second try
db:exec[[INSERT INTO viewed VALUES (?,?),"12/12/12","Alex"]] --DO NOT EXECUTE anything neither returns an error
--Third try
db:exec[[INSERT INTO viewed VALUES (?,?)],["12/12/12","Alex"]] --DO NOT EXECUTE anything neither returns an error
--Fourth try
insert\_stmt = db:prepare[[
INSERT INTO viewed VALUES (?, ?);
INSERT INTO viewed VALUES (?, ?)
]]
function insert(id1, data1, id2, data2)
insert\_stmt:bind(id1, data1, id2, data2)
insert\_stmt:exec()
end
insert( 1, "Hello World", 2, "Hello Lua" )
insert( 3, "Hello Sqlite3", 4, "Hello User" )
This returns the following error in the console
Runtime error
/Users/mac/Desktop/untitled folder/main.lua:34: attempt to call method ‘exec’ (a nil value)
stack traceback:
[C]: in function ‘exec’
/Users/mac/Desktop/untitled folder/main.lua:34: in function ‘insert’
/Users/mac/Desktop/untitled folder/main.lua:37: in main chunk
Runtime error: /Users/mac/Desktop/untitled folder/main.lua:34: attempt to call method ‘exec’ (a nil value)
stack traceback:
[C]: in function ‘exec’
/Users/mac/Desktop/untitled folder/main.lua:34: in function ‘insert’
/Users/mac/Desktop/untitled folder/main.lua:37: in main chunk
Any help from somebody else? [import]uid: 4883 topic_id: 1056 reply_id: 2697[/import]