The SQLite object provides access to the SQLite database system (see http://www.sqlite.org for more information). A companion object, SQLResult, is required for most database operations.
SQLite Constructor
var sqlite = new SQLite()
No arguments are required for the instantiation of an SQLite object. However, all future calls to the database will be through this instance of the object.
SQLite Methods Methods
open
Arguments
on_disk [Number]
must_exist [Number]
Open an SQLite-format file for database operations. The required filename argument is the file to access. The optional on_disk argument determines if the file should be memory-based (0) or disk-based (1). The optional must_exist argument, if non-zero, requires the file to exist to be opened. If zero, then a file will be created if it does not exist.
This method returns an error code if unsuccessful, or a zero if the call results in an opened database.
close
Closes a previously opened SQLite database.
exec
Arguments
result [String]
Perform an SQL command on the database. This command must be in standard SQL language syntax, limited to the operations that SQLite supports. The result argument will return with an SQLResult object (see below) with any applicable results.
The method returns an error code if unsuccessful, or a zero if the call results in a completed operation.
Example:
var res = new SQLResult;
var rtn = sqlite.exec(“CREATE TABLE Persons (PersonID INTEGER, LastName TEXT, FirstName TEXT);”, res);
begintransaction
Start an SQL transaction on the database. This allows you to batch database updates, and to roll back sets of changes if they do not all complete. When you are done with batch updates, a call to endtransaction() should be executed.
endtransaction
Complete a transaction and flush all database writes to the file.
See Also
Name | Description |
---|---|
JavaScript Usage | JavaScript Usage |