Repodb_mariadb

repodb-mariadb · API reference

val default_cache_size : int

MariaDB/MySQL driver for Repodb.

This package exposes a concrete Repodb.Driver.S implementation backed by the blocking MariaDB bindings. It targets MariaDB/MySQL deployments while keeping the same Repodb API used by the SQLite and PostgreSQL drivers.

Basic use:

module Repo = Repodb.Repo.Make (Repodb_mariadb.Driver)

  let conninfo =
    "host=localhost port=3306 user=app password=secret dbname=app"

  let result =
    Repodb_mariadb.with_connection conninfo (fun conn ->
      Repo.all_query conn (Repodb.Query.from User.table) ~decode:decode_user)

Connection info is a whitespace-separated list of key=value pairs. The accepted keys are host, port, user or username, password or pass, db, dbname, database, socket or unix_socket, and charset. Values may be quoted with single or double quotes.

MariaDB does not support every PostgreSQL-oriented feature. In particular, RETURNING support is reported as unavailable and some JSON operations use MySQL JSON functions rather than PostgreSQL operators. Prefer the Query and Expr builders so dialect differences are handled centrally.

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