module Sqlite3:Sqlite3 bindings for OCamlsig..end
type db
type stmt
type argument
typesql_type =[ `BLOB | `FLOAT | `INTEGER | `NULL | `TEXT ]
typesql_value =[ `BLOB of string
| `FLOAT of float
| `INT of int
| `INT64 of int64
| `NULL
| `TEXT of string
| `VALUE of argument ]
type('a, 'b)fmt =('b, unit, string, 'a) format4 -> 'b
type error_code =
| |
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 | *) |
| |
FORMAT |
(* | Auxiliary database format error | *) |
| |
RANGE |
(* | 2nd parameter to sqlite3_bind out of range | *) |
| |
NOTADB |
(* | File opened that is not a database file | *) |
exception Error of error_code * string
val version : stringsqlite3 library version number.val init : unitSqlite3 module is linked in.val open_db : string -> dbval close_db : db -> unitval interrupt : db -> unitval is_complete : string -> boolval last_insert_rowid : db -> int64val changes : db -> intval total_changes : db -> intval get_autocommit : db -> boolval sleep : int -> unitbusy callbackval busy_set : db -> (int -> [ `FAIL | `RETRY ]) -> unitval busy_unset : db -> unitval busy_timeout : db -> int -> unittrace callbackval trace_set : db -> (string -> unit) -> unitval trace_unset : db -> unitprogress callbackval progress_handler_set : db -> int -> (unit -> unit) -> unitval progress_handler_unset : db -> unitval finalize_stmt : stmt -> unitdb; the binding takes care of finalizing
live statements referring to the db being closed. Of course, using a stmt after
it's been manually finalized or after its db has been closed will raise a
Sqlite3.Error exception (with the MISUSE error code).
Statements are collected by the GC so it's not necessary to manually finalize them.
val prepare_one : db -> string -> stmtval prepare_one_f : db -> (stmt, 'a) fmtprepare_one but uses a format string.val reset : stmt -> unitval expired : stmt -> boolsqlite3_expired function.
expired return true if the stmt was finalized by calling Sqlite3.finalize_stmt
or if its db was closed with Sqlite3.close_dbval step : stmt -> [ `DONE | `ROW ]sqlite3_step on the statement. In case of error, a
Sqlite3.Error exception is raised and the stmt is reset, except if the error
is BUSY or MISUSE.val bind : stmt -> int -> sql_value -> unitval bind_parameter_count : stmt -> intval bind_parameter_index : stmt -> string -> intval bind_parameter_name : stmt -> int -> stringval clear_bindings : stmt -> unitval transfer_bindings : stmt -> stmt -> unitval column_blob : stmt -> int -> stringval column_double : stmt -> int -> floatval column_int : stmt -> int -> intval column_int64 : stmt -> int -> int64val column_text : stmt -> int -> stringval column_type : stmt -> int -> sql_typeval data_count : stmt -> intval column_count : stmt -> intval column_name : stmt -> int -> stringval column_decltype : stmt -> int -> stringval value_blob : argument -> stringval value_double : argument -> floatval value_int : argument -> intval value_int64 : argument -> int64val value_text : argument -> stringval value_type : argument -> sql_typeval create_fun_N : db -> string -> (argument array -> sql_value) -> unitval create_fun_0 : db -> string -> (unit -> sql_value) -> unitval create_fun_1 : db -> string -> (argument -> sql_value) -> unitval create_fun_2 : db ->
string -> (argument -> argument -> sql_value) -> unitval create_fun_3 : db ->
string ->
(argument ->
argument -> argument -> sql_value) ->
unitval delete_function : db -> string -> unitval do_step : stmt -> unit
val fold_step : ('a -> stmt -> 'a) -> 'a -> stmt -> 'afold_step f init stmt repeatedly applies Sqlite3.step to
stmt and calls f on each row. The stmt is reset if the
evaluation of f raises an exception.val bind_and_exec : stmt -> sql_value list -> unit
val bind_fetch : stmt ->
sql_value list -> ('a -> stmt -> 'a) -> 'a -> 'a
val fold_prepare : db -> string -> ('a -> stmt -> 'a) -> 'a -> 'afold_prepare db sql f init prepares all statements in the string sql,
calling f for each one.val fold_prepare_bind : db ->
string -> sql_value list -> ('a -> stmt -> 'a) -> 'a -> 'afold_prepare_bind db sql values f init prepares all statements in the string sql,
binding values from the list values and then calling f for each one.
The number of parameters to bind for each statement is determined by
Sqlite3.bind_parameter_count.
val exec : db -> string -> unit
Combines Sqlite3.fold_prepare and Sqlite3.do_step
val fetch : db -> string -> ('a -> stmt -> 'a) -> 'a -> 'a
Combines Sqlite3.fold_prepare and Sqlite3.fold_step
val exec_v : db -> string -> sql_value list -> unit
val fetch_v : db ->
string -> sql_value list -> ('a -> stmt -> 'a) -> 'a -> 'a
val fold_prepare_f : db -> (('a -> stmt -> 'a) -> 'a -> 'a, 'b) fmtval fold_prepare_bind_f : db ->
(sql_value list -> ('a -> stmt -> 'a) -> 'a -> 'a, 'b)
fmtval exec_f : db -> (unit, 'a) fmtval fetch_f : db -> (('a -> stmt -> 'a) -> 'a -> 'a, 'b) fmtval exec_fv : db -> (sql_value list -> unit, 'a) fmtval fetch_fv : db ->
(sql_value list -> ('a -> stmt -> 'a) -> 'a -> 'a, 'b)
fmtval sql_escape : string -> string' is doubled.
sql_escape "abc'def" thus returns "abc''def".
val blob_escape : string -> stringX'abcd' notation).
blob_escape "A\n" thus returns "410a".
val transaction : ?kind:[ `DEFERRED | `EXCLUSIVE | `IMMEDIATE ] ->
db -> (db -> 'a) -> 'aBEGIN is executed, then the function
argument is applied to the db, then COMMIT is executed and the result of the
function is returned. If the function raises an exception, ROLLACK is executed.