package caqti

  1. Overview
  2. Docs
Abstraction over multiple database libraries

Install

Dune Dependency

Authors

Maintainers

Sources

caqti-0.9.0.tbz
sha256=4c84a16d983d0fed2786f536a3fa4d8fa113b8b30b4deea4a74772582d5489b2
md5=42a2e2d3b73d7fbaecc618549aad2865

doc/caqti.v1/Caqti1_sigs/module-type-CONNECTION/index.html

Module type Caqti1_sigs.CONNECTIONSource

The main API as provided after connecting to a resource.

Interface for constructing query parameters.

Interface for extracting result tuples.

Sourcetype 'a io

The IO monad for which the module is specialized.

Sourceval uri : Uri.t

The URI used to connect to the database.

Sourceval driver_info : Caqti_driver_info.t

Information about the database driver which provides this connection.

Sourceval disconnect : unit -> unit io

Calling disconnect () closes the connection to the database and frees up related resources.

Sourceval validate : unit -> bool io

For internal use by Caqti_pool. Tries to ensure the validity of the connection and must return false if unsuccessful.

Sourceval check : (bool -> unit) -> unit

For internal use by Caqti_pool. Called after a connection has been used. check f must call f () exactly once with an argument indicating whether to keep the connection in the pool or discard it.

Returns a description of parameters and returned tuples. What is returned may be limited by what the underlying library supports. The number of paratemers and tuple components should be correct, but the types may be `Unknown.

Querying

Sourceval exec : Caqti1_query.query -> Param.t array -> unit io

exec q params executes a query q(params) which is not expected to return anything.

Sourceval find : Caqti1_query.query -> (Tuple.t -> 'a) -> Param.t array -> 'a io

find_e q params executes q(params) which is expected to return exactly one tuple.

Sourceval find_opt : Caqti1_query.query -> (Tuple.t -> 'a) -> Param.t array -> 'a option io

find q params executes a query q(params) which is expected to return at most one tuple.

Sourceval fold : Caqti1_query.query -> (Tuple.t -> 'a -> 'a) -> Param.t array -> 'a -> 'a io

fold q f params acc executes q(params), composes f over the resulting tuples in order, and applies the composition to acc.

Sourceval fold_s : Caqti1_query.query -> (Tuple.t -> 'a -> 'a io) -> Param.t array -> 'a -> 'a io

fold_s q f params acc executes q(params), forms a threaded composition of f over the resulting tuples, and applies the composition to acc.

Sourceval iter_p : Caqti1_query.query -> (Tuple.t -> unit io) -> Param.t array -> unit io

fold_p q f params executes q(params) and calls f t in the thread monad in parallel for each resulting tuple t. A certain backend may not implement parallel execution, in which case this is the same as iter_s.

Sourceval iter_s : Caqti1_query.query -> (Tuple.t -> unit io) -> Param.t array -> unit io

fold_s q f params executes q(params) and calls f t sequentially in the thread monad for each resulting tuple t in order.

Transactions

Sourceval start : unit -> unit io

Starts a transaction if supported by the underlying database, otherwise does nothing.

Sourceval commit : unit -> unit io

Commits the current transaction if supported by the underlying database, otherwise does nothing.

Sourceval rollback : unit -> unit io

Rolls back a transaction if supported by the underlying database, otherwise does nothing.

OCaml

Innovation. Community. Security.