Repodb.Driver_common.RAW_DRIVER
repodb · API reference
Helpers for implementing concrete database drivers.
Driver packages normally provide only a raw backend binding and then apply Make to obtain the full Driver.S interface. The raw driver is responsible for connection management, placeholder syntax, parameter binding, row construction, and dialect capability flags. The functor adds convenience operations such as query_one, query_fold, query_iter, with_connection, and the standard transaction wrapper.
A minimal backend has this shape:
module Raw = struct
type connection = ...
type error = string
let dialect = Repodb.Driver.Other "example"
let error_message e = e
let error_of_string e = e
let connect conninfo = ...
let close conn = ...
let exec_raw conn sql ~params = ...
let query_raw conn sql ~params = ...
let placeholder i = "?"
let returning_supported = false
let upsert_syntax = `Standard
let last_insert_id conn = ...
end
module Driver = Repodb.Driver_common.Make (Raw)transaction issues BEGIN, COMMIT, and ROLLBACK using exec_raw. If a backend needs savepoints, isolation levels, or non-standard transaction SQL, implement Driver.S directly instead of using this functor.
type connectiontype errorval dialect : Driver.dialectval error_message : error -> stringval error_of_string : string -> errorval connect : string -> (connection, error) resultval close : connection -> unitval exec_raw :
connection ->
string ->
params:Driver.Value.t array ->
(unit, error) resultval query_raw :
connection ->
string ->
params:Driver.Value.t array ->
(Driver.row list, error) resultval placeholder : int -> stringval returning_supported : boolval upsert_syntax : [ `PostgreSQL | `SQLite | `Standard ]val last_insert_id : connection -> (int64, error) result