Command Execution | |
| These commands manage sending commands to the SQLite database. | |
| void | exec (char[] sql, bit(*callback)(char[][char[]] columns)) |
| (This function takes a delegate, not a function pointer) Execute the SQL command. | |
| void | exec (char[] sql, void(*callback)(char[][char[]] columns)) |
| (This function takes a delegate, not a function pointer) Execute the SQL command. | |
| void | exec (char[] sql) |
| (This function takes a delegate, not a function pointer) Execute the SQL command that has no queries. | |
| void | exec (char[] sql, bit(*callback)(char[][] columns)) |
| (This function takes a delegate, not a function pointer) Execute the SQL command. | |
| void | exec (char[] sql, void(*callback)(char[][] columns)) |
| (This function takes a delegate, not a function pointer) Execute the SQL command. | |
| void | exec (char[] sql, bit(*callback)(char[][] names, char[][] values)) |
| (This function takes a delegate, not a function pointer) Execute the SQL command, running a callback that takes parallel names and values columns. | |
| SQLite Query | query (char[] sql) |
| Execute the SQL command and return a query matrix from the results. | |
Public Member Functions | |
| this (char[] filename) | |
| Open the database and read the tables. | |
| ~this () | |
| Close the database. | |
| void | close () |
| Close the database if it is currently open. | |
| void | busyHandler (bit(*func)(char[] tableName, uint busyCount)) |
| (This method takes a delegate, not a function pointer) Assign a busy handler that is called if the database is currently locked. | |
| void | busyNone () |
| Reset the busy handler to the default. | |
| void | busyTimeout (uint milliseconds) |
| Set the busy handler to a function that sleeps when a table is locked, giving control to other threads and processes. | |
| void | attachDatabase (char[] filename, char[] name) |
| Add a pre-existing database file to the current database connection. | |
| void | detachDatabase (char[] databaseName) |
| Detach a table previously attached using the attachDatabase () method. | |
| void | begin (SQLite.OnConflict onConflict) |
| Manually start a transaction. | |
| void | begin () |
| Begin a transaction with the OnConflict.Abort conflict resolution algorithm. | |
| void | beginRollback () |
| Begin a transaction with the OnConflict.Rollback conflict resolution algorithm. | |
| void | end () |
| End a transaction normally. | |
| void | commit () |
| Commit all changes so far done by a transaction and close it. | |
| void | rollback () |
| Roll back any changes made within a transaction and close it. | |
| void | createFunction (char[] name, int argumentCount, char[](*func)(char[][] arguments)) |
| (This method takes a delegate, not a function pointer) Create a user-defined function that can be used in all SQL commands for this database. | |
Table Management | |
These methods create and access tables in the database. Tables are created through the #createTable method. Initially they don't exist in the database; you need to call Table.flush () to store them. See the Table documentation for more details.
Because the tables are extracted from the database, they can get out-of-date to it if another process or thread writes to the database. You can cause a database table to be reloaded using #reloadTables. | |
| Table | createTable (char[] tableName) |
| Create a table object, that is not registered. | |
| Table | table (char[] tableName) |
| Find the table in the database. | |
| Table | table (int index) |
| Return the indexed table. | |
| bit | tableExists (char[] tableName) |
| Return whether a table with this name exists in the database. | |
| int | tableCount () |
| Return the number of tables in all attached databases. | |
| void | reloadTables (char[] databaseName) |
| Reload tables from either the main database or an attached database. | |
Static Public Member Functions | |
| void | privateFunctionBaseString (sqlite_func *sqfunc, int argumentCount, char **argumentPointers) |
|
|
Close the database.
|
|
||||||||||||
|
Add a pre-existing database file to the current database connection. The names 'main' and 'temp' refer to the main database and the database used for temporary tables. These cannot be detached. Attached databases are removed using the detachDatabase () method. You can read from and write to an attached database, but you cannot alter the schema of an attached database. You can only create () and drop () in the original database. You cannot create a new table with the same name as a table in an attached database, but you can attach a database which contains tables whose names are duplicates of tables in the main database. It is also permissible to attach the same database file multiple times. Tables in an attached database can be referred to using the syntax database-name.table-name. If an attached table doesn't have a duplicate table name in the main database, it doesn't require a database name prefix. When a database is attached, all of its tables which don't have duplicate names become the 'default' table of that name. Any tables of that name attached afterwards require the table prefix. If the 'default' table of a given name is detached, then the last table of that name attached becomes the new default. When there are attached databases, transactions are not atomic. Transactions continue to be atomic within each individual database file. But if your machine crashes in the middle of a commit () where you have updated two or more database files, some of those files might get the changes where others might not. There is an SQLite compile-time limit of 10 attached database files. Executing beginTransaction () locks all database files, so this feature cannot (currently) be used to increase concurrency.
|
|
|
Begin a transaction with the OnConflict.Abort conflict resolution algorithm.
|
|
|
Manually start a transaction. No changes can be made to the database except within a transaction. Any command that changes the database (basically, any SQL command other than select ()) will automatically start a transaction if one is not already in effect. Automatically started transactions are committed at the conclusion of the command. Transactions started with this command usually persist until the next commit () or rollback () command. But a transaction will also rollback () if the database is closed or if an error occurs and the OnConflict.Rollback conflict resolution algorithm is specified. Manual transactions are the key to efficient use of SQLite.
|
|
|
Begin a transaction with the OnConflict.Rollback conflict resolution algorithm.
|
|
|
(This method takes a delegate, not a function pointer) Assign a busy handler that is called if the database is currently locked. The default is no handle (a value returned to by calling busyNone ()), in which case a locked database will immediately abort the command and cause an exception.
|
|
|
Reset the busy handler to the default. If a table is locked with the default set, the command is aborted and will cause an exception. |
|
|
Set the busy handler to a function that sleeps when a table is locked, giving control to other threads and processes. Once a certain number of milliseconds have been slept through without the table unlocking, the handler aborts the command with failure.
|
|
|
Close the database if it is currently open. Once closed, no method calls are valid. |
|
|
Commit all changes so far done by a transaction and close it.
|
|
||||||||||||||||
|
(This method takes a delegate, not a function pointer) Create a user-defined function that can be used in all SQL commands for this database.
|
|
|
Create a table object, that is not registered. You need to call create () on the table to register it.
|
|
|
Detach a table previously attached using the attachDatabase () method. This statement will fail if currently within a transaction.
|
|
|
End a transaction normally.
|
|
||||||||||||
|
(This function takes a delegate, not a function pointer) Execute the SQL command, running a callback that takes parallel names and values columns.
|
|
||||||||||||
|
(This function takes a delegate, not a function pointer) Execute the SQL command.
|
|
||||||||||||
|
(This function takes a delegate, not a function pointer) Execute the SQL command.
|
|
|
(This function takes a delegate, not a function pointer) Execute the SQL command that has no queries.
|
|
||||||||||||
|
(This function takes a delegate, not a function pointer) Execute the SQL command.
|
|
||||||||||||
|
(This function takes a delegate, not a function pointer) Execute the SQL command.
|
|
|
Execute the SQL command and return a query matrix from the results. Either there must be a single query in the commands or the columns and column order must be the same in all of them. If this is not true, it will throw an exception.
|
|
|
Reload tables from either the main database or an attached database.
|
|
|
Roll back any changes made within a transaction and close it.
|
|
|
Return the indexed table.
|
|
|
Find the table in the database. If it doesn't exist, throw an error.
|
|
|
Return the number of tables in all attached databases.
|
|
|
Return whether a table with this name exists in the database.
|
|
|
Open the database and read the tables. If the file doesn't exist, it is created.
|
1.3.2