0

I am trying to access a database that I created in SQLiteStudio and I exported it into my project folder. However, I am getting this error:

"File is encrypted or is not a database."

Here is my code:

 --Include sqlite
 require "sqlite3"
 --Open data.db.  If the file doesn't exist it will be created
 local path = system.pathForFile("library.sql", system.ResourceDirectory)
 db = sqlite3.open( path )   

 --Handle the applicationExit event to close the db
 local function onSystemEvent( event )
    if( event.type == "applicationExit" ) then              
        db:close()
    end
end


--print the sqlite version to the terminal
print( "version " .. sqlite3.version() )

--print all the table contents
for row in db:nrows("SELECT * FROM book") do
 local text = row.bookName
 local t = display.newText(text, 20, 30 * row.id, null, 16)
 t:setTextColor(255,0,255)
end

--setup the system listener to catch applicationExit
Runtime:addEventListener( "system", onSystemEvent )

Can you tell me why I am getting this error?

0

1 Answer 1

2

The database is a .db file. You are using a SQL command "script" (or something else). If you create an empty database from command line you should be able to run that script (in sql-command-line or such) and recreate the database. Find where SQLiteStudio saved the actual database, a .db file.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.