Repodb_sqlite

repodb-sqlite · API reference

val default_cache_size : int

SQLite 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 ... end
module Driver : sig ... end
type connection = Driver.connection
type error = Driver.error
val dialect : Repodb.Driver.dialect
val error_message : Driver.error -> string
val connect : string -> (Driver.connection, Driver.error) result
val close : Driver.connection -> unit
val with_connection : 
  string ->
  (Driver.connection -> ('a, Driver.error) result) ->
  ('a, Driver.error) result
val exec : 
  Driver.connection ->
  string ->
  params:Repodb.Driver.Value.t array ->
  (unit, Driver.error) result
val query : 
  Driver.connection ->
  string ->
  params:Repodb.Driver.Value.t array ->
  (Repodb.Driver.row list, Driver.error) result
val query_one : 
  Driver.connection ->
  string ->
  params:Repodb.Driver.Value.t array ->
  (Repodb.Driver.row option, Driver.error) result
val query_fold : 
  Driver.connection ->
  string ->
  params:Repodb.Driver.Value.t array ->
  init:'a ->
  f:('a -> Repodb.Driver.row -> 'a) ->
  ('a, Driver.error) result
val query_iter : 
  Driver.connection ->
  string ->
  params:Repodb.Driver.Value.t array ->
  f:(Repodb.Driver.row -> unit) ->
  (unit, Driver.error) result
val transaction : 
  Driver.connection ->
  (Driver.connection -> ('a, Driver.error) result) ->
  ('a, Driver.error) result
val placeholder : int -> string
val returning_supported : bool
val upsert_syntax : [ `PostgreSQL | `SQLite | `Standard ]
val last_insert_id : Driver.connection -> (int64, Driver.error) result
val driver : Repodb.Driver.driver
val stmt_cache_size : connection -> int