PDA

View Full Version : SQLite Script



Centauri Soldier
02-23-2010, 07:36 PM
I am using the SQLite plugin and am still new at doing the whole "SELECT * FROM ..." stuff and was wondering if anyone has any SQLite functions laying around in a script file somewhere.

Like this...


function SQLIte.GetValue(dbID, sTable, sColumn, sRow)
--Mysterious SQLite code here
return MagicValue
end

function SQLIte.CountRows(dbID, sTable)
--Mysterious SQLite code here
return MagicValue
end

Just to make the reading and writing of data from databases so much simpler. I'm sure (but I don't know how) that functions could be made that would allow a person to do just about every SQLite action there is with ease.

Most of the trouble I'm having is that I can't figure out to get records from a database that contains more than one table. The plugin does not seem to discriminate against multiple tables in a database (or I'm just missing it).

The possibility also exists that I'm just a N00b at this and need to give it some time to sink in in order to find simplicity in the code.

Oh, also, anyone know how to turn on auto vacuum when using the SQLite plugin?

Thanks for reading guys. :)

jassing
02-23-2010, 07:56 PM
sqlite.org has great documentation.

nHandle = SQLite.Open(".\\MyDatabase.db");
tData= SQLite.QueryToTable( nHandle, "Select * from MyTable where lastname='fish';");

Then use the data
tData.Data[1]["FirstName"]
etc.

Someone put together a small sqlite example, perhaps in the plugin directory or examples...

Centauri Soldier
02-23-2010, 08:24 PM
Yes I did find find the website quite useful so far but I think my confusion lies in multiple table handling.

jassing
02-23-2010, 10:56 PM
please don't take this the wrong way -- but this forum might not be the best place to get SQL help on this level.

here's an example that uses multiple tables.

cheesy example...
Some comments -- start in "on start" then "on show" then "on close" and finally "on shutdown"

Centauri Soldier
02-23-2010, 11:08 PM
No, you're probably right, Josh. This may be the wrong place indeed but thank you very much for the example. :yes

jassing
02-23-2010, 11:14 PM
A good 'start' to sqlite (there are differences, and my example uses some shorthand sqlite stuff) is downloading the executable SQLite.exe (The AMS sqlite plugin is version 2, not version 3) and trying things.

Some things don't translate into the sqlite plugin -- for example sometimes views don't work. There's a few gui based sqlite interfaces too.

"Try" and you'll learn -- it's harder learning sqlite via the plugin over using more direct tools.

try and post code/questions.