Hi all,
I’ve been up all night trying to figure this out. I created my sqlite3 db using SQLiteExpert and copied the db to my corona folder. To make sure it was ok I used another tool RazorSQL to make sure it was as I thought and it was.
I have 3 tables in my DB Owner, Player, & Player_Master_Tasks and RazorSQL proved it. Now here is my code:
module(..., package.seeall)
require "sqlite3"
dbName = "kings.sqlite3"
-- Return the path and file name to the Database
function getDatabasePath()
return system.pathForFile(dbName, system.DocumentsDirectory)
end
-- Return a database connection
function getDatabase()
return sqlite3.open(getDatabasePath() )
end
function doesTableExist(inTable)
local doesExist = false
local db = getDatabase()
print("Next is the db")
print (db) -- this is NOT nil
local counter = 0
for row in db:nrows("SELECT name FROM sqlite\_master where type = 'table' LIMIT 3") do
counter = counter +1
print("!!!!!!!! SQLITE\_MASTER table = row.name")
doesExist = true
end -- non of the for loop executes
db:close()
return { doesExist = doesExist }
end
This is the output:
Next is the db
sqlite database (0x19901e4)
OWNER does not exist
When I run the query (cut and past the sql) in RazorSQL it works fine. It shows all three tables. My code doesn’t find one of them!
Any help is appreciated.
[import]uid: 12090 topic_id: 11770 reply_id: 311770[/import]