Repodb_postgresql
repodb-postgresql · API reference
val default_cache_size : intPostgreSQL driver for Repodb.
This package exposes a concrete Repodb.Driver.S implementation backed by the postgresql OCaml bindings. It supports PostgreSQL placeholders, RETURNING, PostgreSQL upsert syntax, binary blobs, UUID values, JSON/JSONB, arrays where Repodb's type layer supports them, and server-side prepared statement caching.
Basic use:
module Repo = Repodb.Repo.Make (Repodb_postgresql.Driver)
let conninfo = "host=localhost dbname=app user=app password=secret"
let result =
Repodb_postgresql.with_connection conninfo (fun conn ->
Repo.all_query conn (Repodb.Query.from User.table) ~decode:decode_user)connect accepts libpq-style connection info. Placeholders render as $1, $2, and so on. Errors are represented as strings at the driver boundary; Repodb.Repo recognizes common PostgreSQL constraint messages and converts them to Repodb.Error.db_error.Constraint_violation.
Raw exposes the backend-specific connection and low-level execution hooks used to build Driver. Prefer Driver and repo abstractions unless you are implementing infrastructure such as migrations, diagnostics, or backend tests.
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.driver