package sqlite3_utils

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
module Data = Sqlite3.Data
module Rc = Sqlite3.Rc
type db = Sqlite3.db
exception RcError of Rc.t

Exception raised by most of the functions below when a Sqlite failure occurs, with the corresponding error code.

exception Type_error of Data.t

Exception raised when the declared Ty.t does not match the actual result returned by Sqlite.

type t = db

Alias for the DB connection

val check_ret : 'a -> Rc.t -> ('a, Rc.t) result

Check return code.

val check_ret_exn : Rc.t -> unit

Check return code.

val setup_timeout : ?ms:int -> t -> unit

on "busy", wait ms milliseconds before failing.

val with_db : ?mode:[ `NO_CREATE | `READONLY ] -> ?mutex:[ `FULL | `NO ] -> ?cache:[ `PRIVATE | `SHARED ] -> ?vfs:string -> ?timeout:int -> string -> (t -> 'a) -> 'a

Temporarily open a DB connection. Parameters follow Sqlite3.db_open.

  • parameter timeout

    if provided, timeout in milliseconds before a query fails with "BUSY".

module Ty : sig ... end

Values representing types to pass to a statement, or to extract from a row

module Cursor : sig ... end
val with_stmt : t -> string -> f:(Sqlite3.stmt -> 'a) -> 'a

Locally make a statement out of the given string, then cleanup when f returns.

val exec0 : t -> string -> (unit, Rc.t) result

Run the query purely for its side effects.

val exec0_exn : t -> string -> unit

Run the query purely for its side effects.

  • raises RcError

    if the query failed.

val exec_raw : t -> string -> f:(Data.t array Cursor.t -> 'b) -> ('b, Rc.t) result
val exec_raw_exn : t -> string -> f:(Data.t array Cursor.t -> 'b) -> 'b
val exec_raw_args : t -> string -> Sqlite3.Data.t array -> f:(Data.t array Cursor.t -> 'b) -> ('b, Rc.t) result
val exec_raw_args_exn : t -> string -> Sqlite3.Data.t array -> f:(Data.t array Cursor.t -> 'b) -> 'b
val exec : t -> string -> ty:(('a, ('res, Rc.t) result) Ty.t * ('b, 'c) Ty.t * 'b) -> f:('c Cursor.t -> 'res) -> 'a
val exec_exn : t -> string -> ty:(('a, 'res) Ty.t * ('b, 'c) Ty.t * 'b) -> f:('c Cursor.t -> 'res) -> 'a
val exec_no_params : t -> string -> ty:(('b, 'c) Ty.t * 'b) -> f:('c Cursor.t -> 'res) -> ('res, Rc.t) result
val exec_no_params_exn : t -> string -> ty:(('b, 'c) Ty.t * 'b) -> f:('c Cursor.t -> 'res) -> 'res
val exec_no_cursor : t -> string -> ty:('a, (unit, Rc.t) result) Ty.t -> 'a
val exec_no_cursor_exn : t -> string -> ty:('a, unit) Ty.t -> 'a
val transact : t -> (t -> 'a) -> 'a
val atomically : t -> (t -> 'a) -> 'a
OCaml

Innovation. Community. Security.