luasqlite3 updates only work with db:exec() ?

Has anyone gotten an Android app working with luasqlite3 calls that use stmt = db:prepare(), stmt:bind…(), stmt:step(), stmt:finalize()?

My iOS app works fine with luasqlite3, but when I run on Kindle Fire, reads (with db:nrows()) and writes with db:exec() work fine, but using prepared UPDATE statements causes “cannot open file” (sqlite3 error code 14, CANTOPEN).

I don’t want to write an entire parameter-binding kludge to handle this, so I’m hoping someone can tell me what the problem is.

Things are definitely different on Android. One problem I already got past is that you can’t do a “break” in a db:nrows() loop – that leaves the Android db connection in a bad state.

So I’m hoping someone has a similar magic answer for bound prepared statements . . .
[import]uid: 25887 topic_id: 26429 reply_id: 326429[/import]

have u set
temp_directory?

try this
local baseDir = system.pathForFile("", system.DocumentsDirectory);
sqlite3.temp_directory(baseDir)

check sqlite3 doc [import]uid: 25057 topic_id: 26429 reply_id: 107209[/import]

@coolseal,

This has to be it, based on your posts from a few days back under sqlite3 (so thanks already!), but I get this when I call sqlite3.temp_directory – it’s like sqlite3.temp_directory is a field, not a function. Did you have this happen?:

local baseDir = system.pathForFile("", system.TemporaryDirectory)
print( baseDir )
print( sqlite3.version() )
sqlite3.temp_directory( baseDir )

Returns:
C:\Users…\trunk-0D651A27536A2C678003A55E2017C312\tmp\
3.6.12

and then

Runtime error
e:\docjournal\trunk\dataClass.lua:777: attempt to call field ‘temp_directory’ (a nil value)
stack traceback:
e:\docjournal\trunk\main.lua:18: iRuntime error: e:\docjournal\trunk\dataClass.lua:777: attempt to call field ‘temp_directory’ (a nil value)

RESOLVED: sqlite3.temp_directory is nil in the simulator, but not in android. This works.
if sqlite3.temp_directory ~= nil then
local baseDir = system.pathForFile("",system.TemporaryDirectory)
sqlite3.temp_directory( baseDir )
end

Thanks, coolseal! [import]uid: 25887 topic_id: 26429 reply_id: 107432[/import]

@RealHandy
that’s great!u improve it
i should use this in my code :slight_smile: [import]uid: 25057 topic_id: 26429 reply_id: 108453[/import]