Repodb_sqlite
repodb-sqlite · API reference
val default_cache_size : intSQLite driver for Repodb.
This package exposes a concrete Repodb.Driver.S implementation backed by the sqlite3 OCaml bindings. It is the easiest backend for tests, local tools, and small applications.
Basic use:
module Repo = Repodb.Repo.Make (Repodb_sqlite.Driver)
let with_db path f =
Repodb_sqlite.with_connection path (fun conn -> f conn)connect accepts the SQLite database path. Use ":memory:" for an in-memory database. SQL placeholders are ?, RETURNING is enabled, and upsert rendering uses SQLite syntax.
SQLite has dynamic typing. The driver maps booleans to integer 0/1, timestamps and dates to text, UUIDs to blobs when encoded through Repodb.Types, and JSON to text. Keep those representations in mind when writing custom SQL or inspecting raw rows.
The Raw module is public for advanced integrations and tests, but most application code should use the values re-exported at the top level or the Driver module with Repodb.Repo.Make.
module Raw : sig ... endmodule Driver : sig ... endtype connection = Driver.connectiontype error = Driver.errorval dialect : Repodb.Driver.dialectval error_message : Driver.error -> stringval connect : string -> (Driver.connection, Driver.error) resultval close : Driver.connection -> unitval with_connection :
string ->
(Driver.connection -> ('a, Driver.error) result) ->
('a, Driver.error) resultval exec :
Driver.connection ->
string ->
params:Repodb.Driver.Value.t array ->
(unit, Driver.error) resultval query :
Driver.connection ->
string ->
params:Repodb.Driver.Value.t array ->
(Repodb.Driver.row list, Driver.error) resultval query_one :
Driver.connection ->
string ->
params:Repodb.Driver.Value.t array ->
(Repodb.Driver.row option, Driver.error) resultval query_fold :
Driver.connection ->
string ->
params:Repodb.Driver.Value.t array ->
init:'a ->
f:('a -> Repodb.Driver.row -> 'a) ->
('a, Driver.error) resultval query_iter :
Driver.connection ->
string ->
params:Repodb.Driver.Value.t array ->
f:(Repodb.Driver.row -> unit) ->
(unit, Driver.error) resultval transaction :
Driver.connection ->
(Driver.connection -> ('a, Driver.error) result) ->
('a, Driver.error) resultval placeholder : int -> stringval returning_supported : boolval upsert_syntax : [ `PostgreSQL | `SQLite | `Standard ]val last_insert_id : Driver.connection -> (int64, Driver.error) resultval driver : Repodb.Driver.driverval stmt_cache_size : connection -> int