My problem is when i make the connection and try to access the table.
I’m using the sqlite manager to create database and tables.
My database is in teh same folder of main.lua
The Error:
[C]: in function 'nrows'
in main chunk
Runtime error: no such table: myTable
My Code:
[code]
require “sqlite3”
myDB=sqlite3.open(‘myBD.sqlite3’)
local function onSystemEvent(event)
if(event.type == “applicationExit”) then
myDB:close();
end
end
for a in myDB:nrows(‘select * from myTable’) do
print(a.name)
end
NOTE: When providing a file path to open(), make sure to use system.pathForFile(). Providing just a plain file name such as “my.db” will not work consistently across the simulator and devices, especially on Android (see system.ResourceDirectory).
Runtime error: no such table: myTable
stack traceback:
[C]: ?
[C]: in function 'nrows'
The code
[code]
local path = system.pathForFile(“myApp.db”, system.DocumentsDirectory)
db = sqlite3.open( path )
local function onSystemEvent(event)
if(event.type == “applicationExit”) then
db:close();
end
end
when you use system.DocumentsDirectory you have to put your database in the same path as your corona sdk installation.
I made it and now works correctly.