Repodb.Driver

repodb · API reference

module Value : sig ... end

Low-level database driver interface shared by all Repodb backends.

type row = {
  columns : string array;
  values : Value.t array;
}
val row_get : row -> string -> Value.t option
val row_get_exn : row -> string -> Value.t
val row_get_idx : row -> int -> Value.t
val row_column_count : row -> int
val row_column_name : row -> int -> string
val row_text : row -> int -> string
val row_text_opt : row -> int -> string option
val row_int : row -> int -> int
val row_int_opt : row -> int -> int option
val row_int64 : row -> int -> int64
val row_int64_opt : row -> int -> int64 option
val row_float : row -> int -> float
val row_float_opt : row -> int -> float option
val row_bool : row -> int -> bool
val row_bool_opt : row -> int -> bool option
val row_is_null : row -> int -> bool
module ColumnIndex : sig ... end
type dialect = 
  | PostgreSQL
  | SQLite
  | MySQL
  | Other of string
val dialect_to_string : dialect -> string
type command_result = {
  affected_rows : int64;
  generated_id : int64 option;
}

Result of a statement that modifies rows.

affected_rows is the number of rows the statement actually changed, which is what a compare-and-set update needs in order to know whether it applied. generated_id carries the auto-generated primary key of an INSERT when the backend can report one, as a full-width int64.

val no_command_result : command_result
type ddl_capabilities = {
  create_table_if_not_exists : bool;
  drop_table_if_exists : bool;
  create_index_if_not_exists : bool;
  drop_index_if_exists : bool;
  add_column_if_not_exists : bool;
  drop_column_if_exists : bool;
}

Which IF [NOT] EXISTS guards a backend actually accepts.

Repodb never emits one of these guards unless the backend is known to support it: MySQL, for instance, accepts CREATE TABLE IF NOT EXISTS but rejects CREATE INDEX IF NOT EXISTS, which MariaDB accepts. Drivers that can identify their server precisely may pass a more permissive record to the DDL renderers; see Repodb_mariadb.detect_ddl_capabilities.

val no_ddl_capabilities : ddl_capabilities
val all_ddl_capabilities : ddl_capabilities
val mysql_ddl_capabilities : ddl_capabilities
val mariadb_ddl_capabilities : ddl_capabilities
val default_ddl_capabilities : dialect -> ddl_capabilities
module type S = sig ... end
type driver = (module S)