Im trying to build a database from a text file containing scrabble words. I cant get the following code to work though, any ideas what Im doing wrong?
[code]
require “sqlite3”
local path = system.pathForFile(“data.db”, system.DocumentsDirectory)
db = sqlite3.open( path )
– local function onSystemEvent( event )
– if( event.type == “applicationExit” ) then
– db:close()
– end
– end
local tablesetup = [[CREATE TABLE IF NOT EXISTS WORD_DATA (WORD_ID TEXT PRIMARY KEY);]]
db:exec( tablesetup )
local path = system.pathForFile( “twl06.txt”, system.DocumentsDirectory )
local fh = io.open( path )
for line in fh:lines() do
print(line)
local tablefill =“INSERT INTO WORD_DATA (WORD_ID) VALUES(’”…line…" ); "
db:exec( tablefill )
end
for row in db:nrows(“SELECT * FROM WORD_DATA”) do
print(row.WORD_ID … " ")
end
[/code] [import]uid: 28912 topic_id: 10414 reply_id: 310414[/import]