【发布时间】:2014-01-18 17:29:42
【问题描述】:
我正在尝试访问我在 SQLiteStudio 中创建的数据库并将其导出到我的项目文件夹中。但是,我收到此错误:
“文件已加密或不是数据库。”
这是我的代码:
--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 )
你能告诉我为什么会出现这个错误吗?
【问题讨论】:
标签: database sqlite lua coronasdk