Database
Heximus supports SQLite databases. The core functions of SQLite are exposed through the Heximus Database control. So lets get started with a simple walkthrough. First things first, create the Database control.
hdb = database("test.db") // creates a blank database if the database does not exist.
p hdb // p is the short form of print. You will be using this command a lot and any typing on a cell phone is a pain so it was simplfied to just "p"
Database=test Closed No active cursor // italics represents heximus responses
We now have a database control but it is not connected to anything.
tablename = "test" // pretty creative table name
eh
a = "CREATE TABLE IF NOT EXISTS " + tablename +
"("
a = a + "ID
INTEGER PRIMARY KEY,"
a = a + "FILENAME TEXT,"
a = a + "SECS1970 INT,"
a = a + "IMAGE BLOB)"
hdb.execSQL a // the execSQL command creates
the table
We can now examine the database.
hdb.schema // dump the schema
android_metadata Table
locale TEXT
test Table
ID INTEGER
FILENAME TEXT
SECS1970 INT
IMAGE BLOB
We now have a table name called test created but it is empty. Time to insert some records.
There there are two ways to insert into a table using either the INSERT command or ContentValue, however using ContentValue is preferred since it less wordy and faster.
b = "INSERT INTO
test(FILENAME,SECS1970) VALUES('ab',42)"
hdb.execSQL b // not using this in this example
cov = contentvalue("t") // using content value
cov.put "FILENAME","myfile"
cov.put "IMAGE","image/audio"
cov.put "SECS1970", 16333322
cov.Insert "test",cov
Which ever method you use, you will now have one record created
Lets query the database.
cur = hdb.select("Select * from test")
The previous line creates a SQLite database cursor. Here the name is "cur" but it can be any name you want