package sqlite3_utils

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Sqlite3_utilsSource

Sourcemodule Data = Sqlite3.Data
Sourcemodule Rc = Sqlite3.Rc
Sourceexception RcError of Rc.t

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

Sourceexception Type_error of Data.t

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

Sourcetype t = db

Alias for the DB connection

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

Check return code.

Sourceval check_ret_exn : Rc.t -> unit

Check return code.

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

on "busy", wait ms milliseconds before failing.

Sourceval 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".

Sourcemodule Ty : sig ... end

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

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

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

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

Run the query purely for its side effects.

Sourceval exec0_exn : t -> string -> unit

Run the query purely for its side effects.

  • raises RcError

    if the query failed.

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