class SQLite

Provides access to the SQLite database system.

A companion object, SQLResult, is required for most database operations.

Index

Constructors

Methods

new SQLite()

new SQLite();

Constructs a new instance of the SQLite class

All future calls to the database will be through this instance of the object.

close()

Close a previously opened SQLite database

close(): void;

endtransaction()

Complete a transaction and flush all database writes to the file

endtransaction(): void;

exec(command, result)

Perform an SQL command on the database

This command must be in standard SQL language syntax, limited to the operations that SQLite supports.

exec(command: string, result: SQLResult): number;
NameTypeDescription
commandstringSQL command
resultSQLResultSQLResult object to populate with transaction results
Return Valuenumberan error code if unsuccessful or 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,
);

lastinsertid()

Get the row ID of the most recently inserted row

lastinsertid(): number;
NameTypeDescription
Return Valuenumberthe row ID of the last successful INSERT operation

open(filename, on_disk, must_exist)

Open an SQLite-format file for database operations

open(filename: string, on_disk?: number, must_exist?: number): number;
NameTypeDescription
filenamestringFile to access
optional on_disknumberIf the file should be memory-based (0) or disk-based (1)
optional must_existnumberIf non-zero, requires the file to exist to be opened, otherwise, a file will be created if one does not exist.
Return Valuenumberan error code if unsuccessful or zero if the call results in an opened database

starttransaction()

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 SQLite.endtransaction() should be executed.

starttransaction(): void;