Repodb.Driver.Value
repodb · API reference
Low-level database driver interface shared by all Repodb backends.
Most applications use this module indirectly through Repo.Make, Pool.Make, Cqrs.Make, or a concrete driver package such as repodb-sqlite. Driver values are still useful when writing a new backend, decoding custom query results, or using low-level SQL execution for tooling.
A driver exposes a small synchronous contract: connect, execute a statement with typed parameters, query rows, run a transaction, and describe dialect features such as placeholders and RETURNING support. Repodb's higher-level modules build SQL with this contract and translate driver errors into Error.db_error where appropriate.
Rows are represented as column names plus Value.t values. Prefer the typed row helpers when decoding:
type user = { id : int64; email : string; active : bool }
let decode_user row =
{
id = Driver.row_int64 row "id";
email = Driver.row_text row "email";
active = Driver.row_bool row "active";
}Optional helpers such as row_text_opt return None for SQL NULL and for failed conversions. The _exn helpers are intended for tests and for decoders where missing columns indicate a programming error.
Backend packages implement S; applications usually instantiate a repo with the concrete driver's Driver module:
module Repo = Repodb.Repo.Make (Repodb_sqlite.Driver)type t =
| Null
| Int of int
| Int64 of int64
| Float of float
| Text of string
| Blob of string
| Bool of boolval null : tval int : int -> tval int64 : int64 -> tval float : float -> tval text : string -> tval blob : string -> tval bool : bool -> tval of_string : string -> tval is_null : t -> boolval to_int : t -> intval to_int_opt : t -> int optionval to_int64 : t -> int64val to_int64_opt : t -> int64 optionval to_float : t -> floatval to_float_opt : t -> float optionval to_string : t -> stringval to_string_opt : t -> string optionval to_bool : t -> boolval to_bool_opt : t -> bool option