A SQLite library for CLIPS
First, you will need sqlite3.h to be available in your system.
If you're on Ubuntu-based systems, for example:
sudo apt install libsqlite3-dev
To compile and run CLIPSQLite locally (without installing globally):
make
./vendor/clips/clips
You could install this globally on your system, too:
make
sudo make install
CLIPSQLite
You can find examples of usage in the program.bat file:
./vendor/clips/clips -f2 program.bat
Returns the version of SQLite compiled into CLIPSQLite.
(println "The SQLite version in use: " (sqlite-libversion))Returns an integer equal to SQLITE_VERSION_NUMBER.
(println "The SQLite version integer: " (sqlite-libversion-number))Returns a pointer to a string constant whose value
is the same as the SQLITE_SOURCE_ID C preprocessor macro.
(println "The SQLite aggregate: " (sqlite-sourceid))Returns whether or not SQLite was compiled with Mutexes or not. NOTE: This does not say whether CLIPS is threadsafe or not; CLIPS is not threadsafe.
(println "Is the compiled SQLite threadsafe?: " (sqlite-threadsafe))Returns the amount of memory currently used by SQLite in bytes.
(println "The current amount of memory used: " (sqlite-memory-used))Returns the highest amount of memory used by SQLite in bytes.
If <SET> is TRUE, sets the memory highwater to the current
amount of bytes used by SQLite and returns the previous highest amount
before the set.
<SET>- ABOOLEANvalue that, if included, sets the highwater number to the current amount of memory in use.
(println "The highest amount of memory used so far by SQLite: " (sqlite-memory-highwater))Returns a SYMBOL that is the name of the compile option
whose constant represents the passed <OPTION-INTEGER>.
<OPTION-INTEGER>- AnINTEGERfor the name of the constant that should be returned.
(println "Compile option 1: " (sqlite-compileoption-get 1))Returns either TRUE or FALSE as to whether a given compile option
was set during compilation.
<OPTION-LEXEME>- ASYMBOLthat represents the compile option constant that you want to determine whether or not it was included during compilation.
(println "Was SQLite compiled with DEFAULT_RECURSIVE_TRIGGERS?: " (sqlite-compileoption-used DEFAULT_RECURSIVE_TRIGGERS))Opens a connection to either an in-memory or file-based database.
<LEXEME>: Either aSYMBOLorSTRINGthat is a file path or:memory:<FLAGS>: ASYMBOLorMULTIFIELDofSYMBOLs of flags to open the database as. Available flags:SQLITE_OPEN_READONLYSQLITE_OPEN_READWRITESQLITE_OPEN_CREATESQLITE_OPEN_URISQLITE_OPEN_MEMORYSQLITE_OPEN_NOMUTEXSQLITE_OPEN_FULLMUTEXSQLITE_OPEN_SHAREDCACHESQLITE_OPEN_PRIVATECACHESQLITE_OPEN_EXRESCODESQLITE_OPEN_NOFOLLOW
- A pointer to the opened database
FALSEupon failure
(defglobal ?*filedb* = (sqlite-open "./foo.db"))
(defglobal ?*in-memorydb* = (sqlite-open :memory:))
(defglobal ?*db-readonly* = (sqlite-open ./foo-readonly.db SQLITE_OPEN_READONLY))
(defglobal ?*db-readonly2* = (sqlite-open ./foo-readonly2.db (create$ SQLITE_OPEN_READONLY SQLITE_OPEN_NOFOLLOW)))Closes a connection to an opened database connection
<db-pointer>: Pointer to an opened database connection
TRUEon successful closeFALSEon failure
(defglobal ?*filedb* = (sqlite-open "./foo.db"))
(println "Successfully closed ?*filedb* ?: " (sqlite-close ?*filedb*))Returns the number of changes that occurred in the database due to the last run query.
<DB-POINTER>- A pointer to an opened connection.
(defglobal ?*stmt* = (sqlite-prepare ?*db* "INSERT INTO foos (name) VALUES ('bar', 'baz')))
(sqlite-step ?*stmt*)
(println "Inserted " (sqlite-changes ?*db*) " records.") ; Inserted 2 records.Returns the total changes made so far on the database connection.
<DB-POINTER>- A pointer to an opened connection.
<INTEGER>- The number of changes<BOOLEAN>-FALSEwhen something goes wrong
(defglobal ?*stmt* = (sqlite-prepare ?*db* "INSERT INTO foos (name) VALUES ('bar', 'baz')))
(sqlite-step ?*stmt*)
(sqlite-finalize ?*stmt*)
(defglobal ?*stmt* = (sqlite-prepare ?*db* "INSERT INTO foos (name) VALUES ('zub', 'zab')))
(println "Inserted " (sqlite-total-changes ?*db*) " records total.") ; Inserted 4 records total.Returns the rowid of the last inserted record. The rowid is always available as an undeclared column named ROWID, OID, or ROWID as long as those names are not also used by explicitly declared columns. If the table has a column of type INTEGER PRIMARY KEY then that column is another alias for the rowid.
<DB-POINTER>- A pointer to an opened connection.
<INTEGER>- THe last inserted rowid<BOOLEAN>-FALSEif something goes wrong
(defglobal ?*stmt* = (sqlite-prepare ?*db* "INSERT INTO foos (name) VALUES ('bar', 'baz')))
(sqlite-step ?*stmt*)
(println "Last inserted id: " (sqlite-last-insert-rowid ?*db*)) ; Last inserted id: 2The name of a database at a given index on an open connection.
<DB-POINTER>- A pointer to an opened connection.<INDEX>- An<INTEGER>indicating the index of the database who's name to return
<STRING>- The name of database on the open db-pointer connection at index.<BOOLEAN>-FALSEif index is out of bounds.
(sqlite-db-name ?*db-in-memory* 0) ; main
(sqlite-db-name ?*db-in-memory* 1) ; temp
(sqlite-db-name ?*db-in-memory* 2) ; FALSEReturns the name of a filename for the opened <DB-POINTER>.
<DB-POINTER>- A pointer to an opened connection.<DB-NAME>- A<LEXEME>that is the name of a database in the opened connection.
<STRING>- The full path to the file for the opened database connection<BOOLEAN>-FALSEif is temporary or in-memory database.
(defglobal ?*db-file* = (sqlite-open ./foo2.db))
(defglobal ?*filename* = (sqlite-db-filename ?*db-file* "main"))
(sub-string (- (str-length ?*filename*) 7) (str-length ?*filename*) ?*filename*) ; "/foo2.db"Returns whether or not a database is readonly.
<DB-POINTER>- A pointer to an opened connection.<DB-NAME>- A<LEXEME>that is the name of a database in the opened connection.
<BOOLEAN>-TRUEif database is readonly on the connection,FALSEif it is not readonly.
(defglobal ?*db* = (sqlite-open ./foo-readonly.db))
(sqlite-db-readonly ?*db* "main") ; FALSE
(sqlite-close ?*db*)
(defglobal ?*db* = (sqlite-open ./foo-readonly.db SQLITE_OPEN_READONLY))
(sqlite-db-readonly ?*db* "main") ; TRUEReturns whether or not a database exists on the connection.
<DB-POINTER>- A pointer to an opened connection.<DB-NAME>- A<LEXEME>that is the name of a database in the opened connection.
<BOOLEAN>-TRUEif database exists on the connection,FALSEif it does not exist.
(defglobal ?*db* = (sqlite-open :memory:))
(sqlite-db-exists ?*db* main) ; TRUE
(sqlite-db-exists ?*db* "temp") ; TRUE
(sqlite-db-exists ?*db* "asdf") ; FALSEPrepares a SQL statement to be executed in database
<DB-POINTER>: Pointer to an opened database connection<SQL-QUERY>: A SQL statementSTRING
<statement-pointer>: A pointer to the prepared statementFALSEon failure
(sqlite-prepare ?*db* "SELECT * FROM foos WHERE id=?")Set the explain mode. This will cause the query to include an EXPLAIN
which provides information about the query in the results instead of the results.
<STATEMENT-POINTER>- A pointer to a prepared statement.<INTEGER>- Mode to set for explain level. Possible modes:0- Original prepared statement1- Behaves as if its SQL text began with "EXPLAIN"2- Behaves as if its SQL text began with "EXPLAIN QUERY PLAN"
<BOOLEAN>-TRUEif explain set successfully,FALSEif unsuccessful
(defglobal ?*stmt-m2* = (sqlite-prepare ?*db* "INSERT INTO foos (name) VALUES ('Foo baz'), ('Baz bat'), ('co cuz')"))
(sqlite-stmt-explain ?*stmt-m2* 2) ; TRUE
(sqlite-column ?*stmt-m2* 3) ; "SCAN 3-ROW VALUES CLAUSE"Returns the mode of explain for the prepared statement.
<STATEMENT-POINTER>- A pointer to a prepared statement.
<STRING>-"EXPLAIN"if1or"EXPLAIN QUERY PLAN"if2<BOOLEAN>-FALSEif not yet set on prepared statement
(sqlite-stmt-isexplain ?*stmt*)Binds values in place of variables in a prepared statement.
<STATEMENT-POINTER>- A pointer to a prepared statement.<POSITION-NAME-OR-VALUE>- If inserting positional values, this could be the first value. In this case, do not include<VALUE>. This can also be a<MULTIFIELD>of positional values. This can also be an<INTEGER>representing the positional parameter to replace. This can also be the named parameter in the prepared statement to replace. This can also be a<FACT>of<INSTANCE>with slots named the same as the named parameters in a prepared statement.[<VALUE>]- If argument 2 is the name of the parameter to replace in the prepared statement, this is the value for that parameter.
(defglobal ?*stmt-o* = (sqlite-prepare ?*db* "SELECT ?1, ?2, ?3"))
(sqlite-bind ?*stmt-o* (create$ "alpha" 42 3.14))
(defglobal ?*stmt-n* = (sqlite-prepare ?*db* "SELECT :x AS xx, :y AS yy"))
(sqlite-bind ?*stmt-n* :y 123)
(sqlite-bind ?*stmt-n* :x "hello")
(defglobal ?*stmt-m4* = (sqlite-prepare ?*db* "SELECT * FROM foos WHERE id=? AND name LIKE ?"))
(sqlite-bind ?*stmt-m4* 1 1)
(sqlite-bind ?*stmt-m4* 2 "%oo b%")
(defglobal ?*stmt-m5* = (sqlite-prepare ?*db* "SELECT * FROM foos WHERE id=@id AND name LIKE @name"))
(defglobal ?*stmt-m6* = (sqlite-prepare ?*db* "SELECT * FROM foos WHERE id=:id AND name LIKE :name"))
(deftemplate @row
(slot @id)
(slot @name))
(deftemplate :row
(slot :id)
(slot :name))
(sqlite-bind ?*stmt-m5* (assert (@row (@id 99) (@name "Some Name")))) ; TRUE
(sqlite-bind ?*stmt-m6* (assert (:row (:id 99) (:name "Some Name")))) ; TRUE
(defclass @ROW
(is-a USER)
(slot @id)
(slot @name))
(defclass :ROW
(is-a USER)
(slot :id)
(slot :name))
(defglobal ?*ins* = (make-instance of @ROW (@id 101) (@name "Different name")))
(sqlite-bind ?*stmt-m5* ?*ins*) ; TRUE
(defglobal ?*ins* = (make-instance of @ROW (@id 123) (@name "A third name")))
(sqlite-bind ?*stmt-m5* (instance-address ?*ins*)) ; TRUE
(defglobal ?*ins* = (make-instance of :ROW (:id 101) (:name "Different name")))
(sqlite-bind ?*stmt-m6* ?*ins*) ; TRUE
(defglobal ?*ins* = (make-instance of :ROW (:id 123) (:name "A third name")))
(sqlite-bind ?*stmt-m6* (instance-address ?*ins*)) ; TRUEDispose of the prepared statement when done with it.
<STATEMENT-POINTER>- A pointer to a prepared statement.
<BOOLEAN>-TRUEif successfully finalized.
(defglobal ?*stmt-o* = (sqlite-prepare ?*db* "SELECT ?1, ?2, ?3"))
(sqlite-finalize ?*stmt-o*) ; TRUEReturn the number of parameters that can be bound to a prepared statement.
<STATEMENT-POINTER>- A pointer to a prepared statement.
<INTEGER>- Number of parameters<BOOLEAN>-FALSEif something went wrong
(defglobal ?*stmt-m4* = (sqlite-prepare ?*db* "SELECT * FROM foos WHERE id=? AND name LIKE ?"))
(sqlite-bind-parameter-count ?*stmt-m4*) ; 2Returns the index of a named parameter in a prepared statement.
<STATEMENT-POINTER>- A pointer to a prepared statement.<PARAMETER-NAME>- The name of the parameter who's index to find.
<INTEGER>- the index of the named parameter<BOOLEAN>-FALSEif parameter with this name is not present in prepared statement
(defglobal ?*stmt-n* = (sqlite-prepare ?*db* "SELECT :x AS xx, :y AS yy"))
(sqlite-bind-parameter-index ?*stmt-n* :x) ; 1
(sqlite-bind-parameter-index ?*stmt-n* :y) ; 2Get the name of a parameter in a prepared statement at the specified index.
<STATEMENT-POINTER>- A pointer to a prepared statement.<PARAMETER-INDEX>- AnINTEGERspecifying the index of the parameter who's name to get
<SYMBOL>- The name of the named parameter at the specified<PARAMETER-INDEX>in the prepared statement<BOOLEAN>-FALSEif something went wrong
(defglobal ?*stmt-n* = (sqlite-prepare ?*db* "SELECT :x AS xx, :y AS yy"))
(sqlite-bind-parameter-name ?*stmt-n* 1) ; :x
(sqlite-bind-parameter-name ?*stmt-n* 2) ; :yGets the query for the prepared statement before parameter replacement takes place.
<STATEMENT-POINTER>- A pointer to a prepared statement.
<STRING>- The SQL query before replacing any variables<BOOLEAN>-FALSEif something went wrong
(defglobal ?*stmt-n* = (sqlite-prepare ?*db* "SELECT :x AS xx, :y AS yy"))
(sqlite-sql ?*stmt-n*) ; "SELECT :x AS xx, :y AS yy"Returns the query of a prepared statement after the bound parameters have been replaced
<STATEMENT-POINTER>- A pointer to a prepared statement.
<STRING>- The SQL query after replacing any variables<BOOLEAN>-FALSEif something went wrong
(defglobal ?*stmt-n* = (sqlite-prepare ?*db* "SELECT :x AS xx, :y AS yy"))
(sqlite-expanded-sql ?*stmt-n*) ; "SELECT NULL AS xx, NULL AS yy"
(sqlite-bind ?*stmt-n* :x "hello")
(sqlite-expanded-sql ?*stmt-n*) ; "SELECT 'hello' AS xx, NULL AS yy"
(sqlite-bind ?*stmt-n* :y 123)
(sqlite-expanded-sql ?*stmt-n*) ; "SELECT 'hello' AS xx, 123 AS yy"<STATEMENT-POINTER>- A pointer to a prepared statement.
Returns the prepared statement to the state it was in
before any sqlite-step functions were called on it.
<STATEMENT-POINTER>- A pointer to a prepared statement.
<BOOLEAN>-TRUEif successfully reset,FALSEif something went wrong
(sqlite-reset ?*stmt-n*) ; TRUE
(sqlite-step ?*stmt-n*) ; SQLITE_ROW
(sqlite-step ?*stmt-n*) ; SQLITE_DONE
(sqlite-reset ?*stmt-n*) ; TRUE
(sqlite-step ?*stmt-n*) ; SQLITE_ROWClear bound variables from a prepared statement.
<STATEMENT-POINTER>- A pointer to a prepared statement.
<BOOLEAN>-TRUEif successfully cleared bound variables,FALSEif not
(sqlite-expanded-sql ?*stmt-o*) ; "SELECT 'alpha', 42, 3.14"
(sqlite-clear-bindings ?*stmt-o*)
(sqlite-expanded-sql ?*stmt-o*) ; "SELECT NULL, NULL, NULL""Executes" the SQL query, moving to the next row of results.
Call this multiple times to iterate through results of a SELECT.
<STATEMENT-POINTER>- A pointer to a prepared statement.
SQLITE_ROW- The statement is now pointed at a result rowSQLITE_DONE- There are no more results to iterate
(defglobal ?*stmt-o* = (sqlite-prepare ?*db* "SELECT ?1, ?2, ?3"))
(sqlite-bind ?*stmt-o* (create$ "alpha" 42 3.14))
(sqlite-step ?*stmt-o*) ; SQLITE_ROW
(sqlite-step ?*stmt-o*) ; SQLITE_DONEReturns a multifield with values from the current row of a prepared statement
after a sqlite-step.
<STATEMENT-POINTER>- A pointer to a prepared statement.
<MULTIFIELD>- A multifield with values from the current row of a prepared statemnt.<BOOLEAN>-FALSEif something went wrong
(defglobal ?*stmt-m4* = (sqlite-prepare ?*db* "SELECT * FROM foos WHERE id=? AND name LIKE ?"))
(sqlite-bind ?*stmt-m4* 1 1)
(sqlite-bind ?*stmt-m4* 2 "%oo b%")
(sqlite-step ?*stmt-m4*)
(sqlite-row-to-multifield ?*stmt-m4*) ; (1 "Foo baz")Returns an asserted Fact with the slot values from the current row of a prepared statement.
<STATEMENT-POINTER>- A pointer to a prepared statement.<DEFTEMPLATE-NAME>- A symbol of a deftemplate of the fact that should be asserted from the current row of the prepared statement
<FACT>- The asserted fact with values from the prepared statement row<BOOLEAN>-FALSEif something went wrong
(defglobal ?*stmt-m4* = (sqlite-prepare ?*db* "SELECT * FROM foos WHERE id=? AND name LIKE ?"))
(sqlite-bind ?*stmt-m4* 1 1)
(sqlite-bind ?*stmt-m4* 2 "%oo b%")
(sqlite-step ?*stmt-m4*)
(deftemplate row
(slot id)
(slot name))
(sqlite-row-to-fact ?*stmt-m4* row) ; <Fact-1>
(ppfact 1) ; (row
; (id 1)
; (name "Foo baz"))(sqlite-row-to-instance <STATEMENT-POINTER> <DEFCLASS-NAME> [<INSTANCE-NAME>] [<NAME-COLUMN-SLOT>]) -> INSTANCE or BOOLEAN
Returns the current row of the prepared statement as a COOL instance.
<STATEMENT-POINTER>- A pointer to a prepared statement.<DEFCLASS-NAME>- The name of the defclass for which the instance should be made from[<INSTANCE-NAME>] - The name of the instance to make. Optional ornil` to leave default[<NAME-COLUMN-SLOT>]- Since defclasses can't have a slot namedname, this allows specifying the name of the slot which will be set with the value from the query result'snamecolumn. Leave empty to use the default_name
<INSTANCE>- An instance for a given defclass with slots set to values from the columns of a result of the prepared statement<BOOLEAN>-FALSEif something went wrong
(defglobal ?*stmt-m4* = (sqlite-prepare ?*db* "SELECT * FROM foos WHERE id=? AND name LIKE ?"))
(sqlite-bind ?*stmt-m4* 1 1)
(sqlite-bind ?*stmt-m4* 2 "%oo b%")
(sqlite-step ?*stmt-m4*)
(defclass ROW
(is-a USER)
(slot id)
(slot _name))
(defglobal ?*instance* = (sqlite-row-to-instance ?*stmt-m4* ROW))
(instance-name ?*instance*) ; [gen-1]
(send ?*instance* get-id) ; 1
(send ?*instance* get-_name) ; "Foo baz"Returns the number of columns for the records of the prepared statement.
<STATEMENT-POINTER>- A pointer to a prepared statement.
<INTEGER>- The number of columns<BOOLEAN>-FALSEif something went wrong
(defglobal ?*stmt-o* = (sqlite-prepare ?*db* "SELECT ?1, ?2, ?3"))
(sqlite-column-count ?*stmt-o*) ; 3Returns the name of the database the column in the results is from
<STATEMENT-POINTER>- A pointer to a prepared statement.<COLUMN-INDEX>- The index of the column to return the name of the database from
<STRING>- The name of the database the column is from<BOOLEAN>-FALSEif something goes wrong
(defglobal ?*stmt-o* = (sqlite-prepare ?*db* "SELECT ?1, ?2, ?3"))
(sqlite-step ?*stmt-o*)
(sqlite-column-database-name ?*stmt-o* 1) ; FALSE
(defglobal ?*stmt-m4* = (sqlite-prepare ?*db* "SELECT * FROM foos WHERE id=? AND name LIKE ?"))
(sqlite-step ?*stmt-m4*)
(sqlite-column-database-name ?*stmt-m4* 1)Return the original name of the column that provides the values for the given column index.
<STATEMENT-POINTER>- A pointer to a prepared statement.<COLUMN-INDEX>- The index of the column to return the column name from
<STRING>- The name of the origin column<BOOLEAN>-FALSEif something goes wrong or if there is no origin column
(defglobal ?*stmt-o* = (sqlite-prepare ?*db* "SELECT ?1, ?2, ?3"))
(sqlite-step ?*stmt-o*)
(sqlite-column-origin-name ?*stmt-o* 1) ; FALSE
(defglobal ?*stmt-m4* = (sqlite-prepare ?*db* "SELECT * FROM foos WHERE id=? AND name LIKE ?"))
(sqlite-step ?*stmt-m4*)
(sqlite-column-origin-name ?*stmt-m4* 1) ; "name"Return the name of the table the column comes from in a prepared statement
<STATEMENT-POINTER>- A pointer to a prepared statement.<COLUMN-INDEX>- The index of the column to return the column name from
<STRING>- The name of the table<BOOLEAN>-FALSEif something goes wrong or the column does not come from a table
(defglobal ?*stmt-o* = (sqlite-prepare ?*db* "SELECT ?1, ?2, ?3"))
(sqlite-step ?*stmt-o*)
(sqlite-column-table-name ?*stmt-o* 1) ; FALSE
(defglobal ?*stmt-m4* = (sqlite-prepare ?*db* "SELECT * FROM foos WHERE id=? AND name LIKE ?"))
(sqlite-step ?*stmt-m4*)
(sqlite-column-table-name ?*stmt-m4* 1) ; "foos"Returns the name of the column at column index in a statement
<STATEMENT-POINTER>- A pointer to a prepared statement.<COLUMN-INDEX>- The index of the column to return the column name from
<STRING>- The name of the column<BOOLEAN>-FALSEif something goes wrong or the column does not have a name
(defglobal ?*stmt-o* = (sqlite-prepare ?*db* "SELECT ?1, ?2, ?3"))
(sqlite-step ?*stmt-o*)
(sqlite-column-name ?*stmt-o* 0) ; ?1
(defglobal ?*stmt-n* = (sqlite-prepare ?*db* "SELECT :x AS xx, :y AS yy"))
(sqlite-step ?*stmt-n*)
(sqlite-column-name ?*stmt-n* 1) ; yyReturns the type of column at index
<STATEMENT-POINTER>- A pointer to a prepared statement.<COLUMN-INDEX>- The index of the column to return the column name from
<SYMBOL>- The type of the column. Possible values:SQLITE_INTEGERSQLITE_FLOATSQLITE_TEXTSQLITE_BLOBSQLITE_NULL
<BOOLEAN>-FALSEif something goes wrong or the column does not have a type
(defglobal ?*stmt-o* = (sqlite-prepare ?*db* "SELECT ?1, ?2, ?3"))
(sqlite-step ?*stmt-o*)
(sqlite-column-type ?*stmt-o* 0) ; SQLITE_TEXT
(sqlite-column-type ?*stmt-o* 1) ; SQLITE_INTEGER
(sqlite-column-type ?*stmt-o* 2) ; SQLITE_FLOATReturns the value of column at column index
<STATEMENT-POINTER>- A pointer to a prepared statement.<COLUMN-INDEX>- The index of the column to return the column name from
<STRING>-SQLITE_TEXTorSQLITE_BLOB<INTEGER>-SQLITE_INTEGER<DOUBLE>-SQLITE_FLOATnil-SQLITE_NULL<BOOLEAN>-FALSEif type is not recognized
(defglobal ?*stmt-m4* = (sqlite-prepare ?*db* "SELECT * FROM foos WHERE id=? AND name LIKE ?"))
(sqlite-step ?*stmt-m4*)
(sqlite-column ?*stmt-m4* 1) ; "Foo baz"Returns the latest error that occurred in the database.
<DB-POINTER>: Pointer to an opened database connection
<STRING>- A message describing the last error that occurred<BOOLEAN>-FALSEif something went wrong
(defglobal ?*stmt-o* = (sqlite-prepare ?*db* "SELECT ?1, ?2, ?3"))
(sqlite-close ?*db*)
(sqlite-errmsg ?*db*) ; "unable to close due to unfinalized statements or unfinished backups"Sets the amount of time to wait for a busy query
<STATEMENT-POINTER>- A pointer to a prepared statement.<MILLISECONDS>- An<INTEGER>to set the number of milliseconds to wait
<BOOLEAN>-TRUEon success orFALSEon failure
(sqlite-busy-timeout ?*db* 0)Get or Set a SQLite limit.
<STATEMENT-POINTER>- A pointer to a prepared statement.<LIMIT>- An<INTEGER>or<SYMBOL>of a limit that may be set. You may set<INTEGER>value 0 through 11. Possible<SYMBOL>values:SQLITE_LIMIT_LENGTHSQLITE_LIMIT_SQL_LENGTHSQLITE_LIMIT_COLUMNSQLITE_LIMIT_EXPR_DEPTHSQLITE_LIMIT_COMPOUND_SELECTSQLITE_LIMIT_VDBE_OPSQLITE_LIMIT_FUNCTION_ARGSQLITE_LIMIT_ATTACHEDSQLITE_LIMIT_LIKE_PATTERN_LENGTHSQLITE_LIMIT_VARIABLE_NUMBERSQLITE_LIMIT_TRIGGER_DEPTHSQLITE_LIMIT_WORKER_THREADS
<AMOUNT>- An<INTEGER>to set to the limit
<INTEGER>- The previous limit before running this command<BOOLEAN>-FALSEif something went wrong
(sqlite-limit ?*db* 0) ; 1000000000
(sqlite-limit ?*db* SQLITE_LIMIT_LENGTH) ; 1000000000
(sqlite-limit ?*db* 0 999999999) ; 1000000000
(sqlite-limit ?*db* 0) ; 999999999Pause execution of the thread for a number of milliseconds.
<MILLISECONDS>- AnINTEGERthat is the number of milliseconds to sleep the current thread.
INTEGER- The number of milliseconds of sleep actually requested from the operating system.BOOLEAN-FALSEif anything goes wrong.
(sqlite-backup-init <DESTINATION-DATABASE-POINTER> <DESTINATION-DATABASE-NAME> <SOURCE-DATABASE-POINTER> <SOURCE-DATABASE-NAME>) -> POINTER or BOOLEAN
Initializes database backup from a source to destination database.
<DESTINATION-DATABASE-POINTER>- A pointer to a database connection which will receive the backup data.<DESTINATION-DATABASE-NAME>- The database into which the data will be added.<SOURCE-DATABASE-POINTER>- A pointer to a database connection who's data will be backed up.<SOURCE-DATABASE-NAME>- The database from which the data will be backed up.
<POINTER>- A pointer to an initaizlied backup.<BOOLEAN>-FALSEif initialization failed.
Executes a "page" of backup
<BACKUP-POINTER>- A pointer to an initialized backup.<PAGES>- A number of pages to backup. A negative number means all remaining pages
<SYMBOL>- The status after running a step of the backup<INTEGER>- Some other return code<BOOLEAN>-FALSEif something went wrong
(sqlite-backup-step ?*backup* -1) ; SQLITE_DONEReturns how many pages total are in the backup
<BACKUP-POINTER>- A pointer to an initialized backup.
<INTEGER>- The number of pages total in the backup<BOOLEAN>-FALSEif something went wrong
(sqlite-backup-pagecount ?*backup*) ; 1Returns how many pages of backing up are left before the backup is complete
<BACKUP-POINTER>- A pointer to an initialized backup.
<INTEGER>- The number of pages remaining in the backup<BOOLEAN>-FALSEif something went wrong
(sqlite-backup-remaining ?*backup*) ; 1Cleans up the backup once finished.
<BACKUP-POINTER>- A pointer to an initialized backup.
<BOOLEAN>-TRUEon success,FALSEon failure
(sqlite-backup-finish ?*backup*) ; TRUEmake clean