module Make:
type ('a, 'b)
statement = {
}
Type of SQL statements (no output parameters).
type ('a, 'b, 'c)
expression = {
|
statement : ('a, 'c) statement ; |
|
get_data : int * (Sqlite3.Data.t array -> 'b) ; |
}
Type of SQL expressions (output parameters).
exception Error of exn
Exception identical to the toplevel Error
, provided for convenience.
Note that Sqlexpr_sqlite.Error _
matches this exception.
exception Sqlite_error of string * Sqlite3.Rc.t
Exception identical to the toplevel
Sqlite_error
, provided for
convenience. Note that
Sqlexpr_sqlite.Sqlite_error _
matches this
exception.
Same as the top-level one, provided for convenience.
val open_db : string -> Sqlexpr_sqlite.db
val close_db : Sqlexpr_sqlite.db -> unit
Same as the top-level one, provided for convenience.
val sqlite_db : Sqlexpr_sqlite.db -> Sqlite3.db
Same as the top-level one, provided for convenience.
val execute : Sqlexpr_sqlite.db -> ('a, unit M.t) statement -> 'a
Execute a SQL statement.
val insert : Sqlexpr_sqlite.db -> ('a, int64 M.t) statement -> 'a
Execute an INSERT SQL statement and return the last inserted row id.
Example:
insert db sqlc"INSERT INTO users(name, pass) VALUES(%s, %s)" name pass
val select : Sqlexpr_sqlite.db ->
('a, 'b M.t, 'b list M.t) expression -> 'a
"Select" a SELECT SQL expression and return a list of tuples; e.g.
select db sqlc"SELECT @s{name}, @s{pass} FROM users"
select db sqlc"SELECT @s{pass} FROM users WHERE id = %L" user_id
val select_f : Sqlexpr_sqlite.db ->
('a -> 'b M.t) -> ('c, 'a, 'b list M.t) expression -> 'c
select_f db f expr ...
is similar to select db expr ...
but maps the
results using the provided f
function.
val select_one : Sqlexpr_sqlite.db ->
('a, 'b M.t, 'b M.t) expression -> 'a
select_one db expr ...
takes the first result from
select db expr ...
.
Raises Not_found
if no row is found.
val transaction : Sqlexpr_sqlite.db -> (Sqlexpr_sqlite.db -> 'a M.t) -> 'a M.t
Run the provided function in a DB transaction. A rollback is performed
if an exception is raised inside the transaction.
val fold : Sqlexpr_sqlite.db ->
('a -> 'b -> 'a M.t) ->
'a -> ('c, 'b, 'a M.t) expression -> 'c
fold db f a expr ...
is
f (... (f (f a r1) r2) ...) rN
where rN
is the n-th row returned for the SELECT expression expr
.
val iter : Sqlexpr_sqlite.db ->
('a -> unit M.t) -> ('b, 'a, unit M.t) expression -> 'b
Iterate through the rows returned for the supplied expression.
module Directives: sig
.. end
Module used by the code generated for SQL literals.
module Conversion: sig
.. end
Module used by the code generated for SQL literals.