I’m implementing a simple sql database for my app, but i’m having a couple of problems
the code for creating the file:
[lua]
local path = system.pathForFile(“data.db”,system.ResourcesDirectory)
local db = sqlite3.open( path )
local tablesetup = [[CREATE TABLE IF NOT EXISTS test (id, array);]]
db:exec( tablesetup )
db:exec(“BEGIN TRANSACTION”)
for key,value in pairs(dicionario) do
local insertQuery = [[INSERT INTO test VALUES (’]]…key…[[’,’]]…value…[[’);]]
db:exec( insertQuery )
end
db:exec(“COMMIT”) [/lua]
dicionario is a lua table that serves as a hashtable that i’m building the sql file from. key/id is the hashcode and value/array is an array of words that doesnt have a fixed size, going from 1 to ~20 values. The problem is that the program is not letting me concatenate a table in the query. If I try to put just a single value it goes fine.
Continuing…
I use something like this code to access the data:
[lua]
for p in db:nrows([[SELECT * FROM test WHERE id=’]]…“aaelms”…[[’;]]) do
print(p,p.array)
end [/lua]
I have to acces this data systematically but this way it is taking a looooot of time in my time-critical routine
Is there a smarter way to do this?