0
我想訪問我在SQLiteStudio中創建的數據庫,並將其導出到我的項目文件夾中。但是,我收到此錯誤:Lua中的數據庫訪問
「文件被加密或不是數據庫。」
這裏是我的代碼:
--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)
你能告訴我爲什麼我收到這個錯誤?
謝謝你,Schollii。 =) –