package mariadb

  1. Overview
  2. Docs

Module type Mariadb.SSource

The MariaDB blocking interface.

Sourcetype error = int * string

The type of errors that can result from MariaDB API calls.

Sourcetype 'a result = ('a, error) result

The result of MariaDB API calls.

Sourcemodule Time : sig ... end

Module representing MariaDB date- and time-related values.

Sourcemodule Field : sig ... end

This module defines a database field retrieved by a query.

Sourcemodule Row : sig ... end

A module representing database rows. Rows can be retrieved as different data structures, which as passed to the row retrieval functions from the Res module. There's built-in support for fetching rows as arrays and maps and hash tables of field name to field, but any module conforming to Row.S can be provided to those functions.

Sourcemodule Res : sig ... end

The module containing operations on MariaDB query results.

Sourcemodule Stmt : sig ... end

The module contains operations on MariaDB prepared statements.

Sourcetype t

The type of database handles.

Sourcetype flag =
  1. | Compress
  2. | Found_rows
  3. | Ignore_sigpipe
  4. | Ignore_space
  5. | Interactive
  6. | Local_files
  7. | Multi_results
  8. | Multi_statements
  9. | No_schema
  10. | Odbc
  11. | Ssl
  12. | Remember_options
Sourcetype protocol =
  1. | Default
  2. | Tcp
  3. | Socket
  4. | Pipe
  5. | Memory
Sourcetype client_option =
  1. | Connect_timeout of int
  2. | Compress
  3. | Named_pipe of string
  4. | Init_command of string
  5. | Read_default_file of string
  6. | Read_default_group of string
  7. | Set_charset_dir of string
  8. | Set_charset_name of string
  9. | Local_infile of bool
  10. | Protocol of protocol
  11. | Shared_memory_base_name of string
  12. | Read_timeout of int
  13. | Write_timeout of int
  14. | Secure_auth of bool
  15. | Report_data_truncation of bool
  16. | Reconnect of bool
  17. | Ssl_verify_server_cert of bool
  18. | Plugin_dir of string
  19. | Default_auth of string
  20. | Bind of string
  21. | Ssl_key of string
  22. | Ssl_cert of string
  23. | Ssl_ca of string
  24. | Ssl_capath of string
  25. | Ssl_cipher of string
  26. | Ssl_crl of string
  27. | Ssl_crlpath of string
  28. | Connect_attr_reset
  29. | Connect_attr_add of string * string
  30. | Connect_attr_delete of string
  31. | Server_public_key of string
  32. | Enable_cleartext_plugin of bool
Sourcetype server_option =
  1. | Multi_statements of bool
Sourceval connect : ?host:string -> ?user:string -> ?pass:string -> ?db:string -> ?port:int -> ?socket:string -> ?flags:flag list -> ?options:client_option list -> unit -> t result

Connect to a MariaDB server at the specified location with the specified flags and optionally select a database db.

Sourceval close : t -> unit

Close a database handle.

Sourceval library_end : unit -> unit

library_end () should be called when you're done using the library. For maximum portability across MariaDB C client libraries, call this function only once, after you've closed all database handles.

Sourceval set_character_set : t -> string -> unit result

Sets the connection character set to the given parameter.

Sourceval select_db : t -> string -> unit result

select_db mariadb db changes the current database to db.

Sourceval change_user : t -> string -> string -> string option -> unit result

change_user mariadb user pass db changes the connection user to user with password password and optionally change to database db.

Sourceval set_client_option : t -> client_option -> unit

Sets the given client option on the connection.

Sourceval set_server_option : t -> server_option -> unit result

Sets the given server option on the connection.

Sourceval ping : t -> unit result

Checks if the connection to the MariaDB server is working. If the Reconnect option is set and the connection is down, a reconnect attempt will be made.

Sourceval autocommit : t -> bool -> unit result

Sets autocommit mode on or off.

Sourceval start_txn : t -> unit result
Sourceval commit : t -> unit result

Commits the current transaction.

Sourceval rollback : t -> unit result

Rolls back the current transaction. Does not work if autocommit is enabled.

Sourceval prepare : t -> string -> Stmt.t result

prepare mariadb query creates a prepared statement for query. The query may contain ? as placeholders for parameters that can be bound by calling Stmt.execute.