sqlite.Database
generated from ../src/mod_sqlite/db.cppImplements a sqlite database
Constants
| Name | Description |
|---|---|
| OK | Successful result |
| ERROR | SQL error or missing database |
| INTERNAL | An internal logic error in SQLite |
| PERM | Access permission denied |
| ABORT | Callback routine requested an abort |
| BUSY | The database file is locked |
| LOCKED | A table in the database is locked |
| NOMEM | A malloc() failed |
| READONLY | Attempt to write a readonly database |
| INTERRUPT | Operation terminated by sqlite_interrupt() |
| IOERR | Some kind of disk I/O error occurred |
| CORRUPT | The database disk image is malformed |
| NOTFOUND | (Internal Only) Table or record not found |
| FULL | Insertion failed because database is full |
| CANTOPEN | Unable to open the database file |
| PROTOCOL | Database lock protocol error |
| EMPTY | (Internal Only) Database table is empty |
| SCHEMA | The database schema changed |
| TOOBIG | Too much data for one row of a table |
| CONSTRAINT | Abort due to constraint violation |
| MISMATCH | Data type mismatch |
| MISUSE | Library used incorrectly |
| NOLFS | Uses OS features not supported on host |
| AUTH | Authorization denied |
| ROW | step has another row ready |
| DONE | step has finished executing |
| DENY | |
| INSERT | |
| DELETE | |
| UPDATE |
Class Methods
complete
complete(SQL) : Boolean
| Name | Type | Default | Description |
|---|---|---|---|
| SQL | String | An SQL string |
This function returns true if the given input string comprises one or more complete SQL statements
Constructor
Database
Database(Filename)
| Name | Type | Default | Description |
|---|---|---|---|
| Filename | String | The name of the database file |
Constructs a new SQLiteDatabase object.
When the filename is relative the path will be resolved
to the path of the active script.
Properties
| Name | Type | Description |
|---|---|---|
autocommit ![]() |
Boolean | Test to see whether or not the database connection is in autocommit mode. Return TRUE if it is and FALSE if not. Autocommit mode is on by default. Autocommit is disabled by a BEGIN statement and reenabled by the next COMMIT or ROLLBACK. |
changes ![]() |
Integer | This property returns the number of database rows that were changed (or inserted or deleted) by the most recently completed INSERT, UPDATE, or DELETE statement. Only changes that are directly specified by the INSERT, UPDATE, or DELETE statement are counted. Auxiliary changes caused by triggers are not counted. See totalChanges |
errMsg ![]() |
String | Returns the error message from the most recent sqlite method call. |
errNo ![]() |
Integer | Returns the error number from the most recent sqlite method call. |
lastInsertRowID ![]() |
Double |
Each entry in an SQLite table has a unique integer key called the "rowid".
The rowid is always available as an undeclared column named ROWID, OID, or _ROWID_.
If the table has a column of type INTEGER PRIMARY KEY then that column is
another an alias for the rowid.
This property returns the rowid of the most recent INSERT into the database from the database connection. If no inserts have ever occurred on this database connection, zero is returned. If an INSERT occurs within a trigger, then the rowid of the inserted row is returned by this routine as long as the trigger is running. But once the trigger terminates, the value returned by this routine reverts to the last value inserted before the trigger fired. |
| onCommit | Function | Register a callback function to be invoked whenever a new transaction is committed. If the callback function returns non-zero, then the commit is converted into a rollback. |
| onRollback | Function | Register a callback to be invoked whenever a transaction is rolled back. |
| onTrace | Function | Register a function that is called each time an SQL statement is evaluated. The function receives the SQL statement as argument. |
| onUpdate | Function |
Register a callback function with the database to be invoked whenever a row is updated,
inserted or deleted.
The function gets 4 arguments: The first argument is one of SQLite.INSERT, SQLite.DELETE or SQLite.UPDATE, depending on the operation that caused the callback to be invoked. The second and third arguments to the callback contains the database and table name from the affected row. The final callback parameter is the rowid of the row. In the case of an update, this is the rowid after the update takes place. |
opened ![]() |
Boolean | Returns true when the database was successfully opened |
totalChanges ![]() |
Integer | Use this property to find the total number of changes including changes caused by triggers. See changes |
Methods
execute
execute(SQL) : Integer
| Name | Type | Default | Description |
|---|---|---|---|
| SQL | String | An SQL statement |
Executes an SQL statement immediately.
prepare
prepare(SQL) : Statement
| Name | Type | Default | Description |
|---|---|---|---|
| SQL | String | An SQL statement |
To execute an SQL query, it must first be compiled into a byte-code program using prepare.

© 2002 - 2007 Franky Braem.