module Sqlite3EZ:sig
..end
Sqlite3
with a simplified interfacemodule Rc:sig
..end
module Data:sig
..end
exception Rc of Rc.t
exception Finally of exn * exn
type
db
val db_open : ?mode:[ `NO_CREATE | `READONLY ] ->
?mutex:[ `FULL | `NO ] ->
?cache:[ `PRIVATE | `SHARED ] -> ?vfs:string -> string -> db
as Sqlite3.db_open
val db_close : db -> unit
val with_db : ?mode:[ `NO_CREATE | `READONLY ] ->
?mutex:[ `FULL | `NO ] ->
?cache:[ `PRIVATE | `SHARED ] ->
?vfs:string -> string -> (db -> 'a) -> 'a
with_db filename f
opens a database, applies f
, and returns the
result. The database is closed after f
is evaluated, even if it raises an
exception.val transact : db -> (db -> 'a) -> 'a
transact db f
evaluates f db
within a BEGIN..COMMIT transaction. If f
db
evaluates successfully to y
, the transaction is committed and y
is
returned. If the evaluation of f db
raises an exception, the transaction is
rolled back and the exception is re-raised.
Note that BEGIN..COMMIT transactions cannot be nested in SQLite. Any attempt
to make a nested call to transact
will raise an exception.
val atomically : db -> (db -> 'a) -> 'a
atomically db f
evaluates f db
within a SAVEPOINT..RELEASE
transaction, which may be nested.
This implementation allows only parenthetically nested transactions, so there
is no need to name savepoints.
val exec : db -> string -> unit
val last_insert_rowid : db -> Int64.t
Sqlite3.last_insert_rowid
val changes : db -> int
Sqlite3.changes
type
statement
val make_statement : db -> string -> statement
Sqlite3.reset
are handled automatically). The statement is not actually
compiled until its first use.val statement_exec : statement -> Data.t array -> unit
val statement_query : statement ->
Data.t array ->
(Data.t array -> 'a) -> ('a -> 'b -> 'b) -> 'b -> 'b
statement_query stmt params cons fold init
binds the given parameters
and executes a query. Each result row is first passed to cons
, which will
usually construct a value from the data. This value is then passed to fold
along with an intermediate value, which is init
for the first row. This can
used to build a list or other data structure from all the results.val statement_finalize : statement -> unit