package caqti

  1. Overview
  2. Docs
Unified interface to relational database libraries

Install

Dune Dependency

Authors

Maintainers

Sources

caqti-v1.5.0.tbz
sha256=9524c75c87677eb75e68fbbf421d84b7b610bf2f344bfa227e23465644e62e26
sha512=8c1f289d269d0017bf8b489e64c1153448c62f79a991349662722f4de74c0cbbd75dcdca266b7276af55200346d38dce8135da247e5fbc235a3660785a03b01f

doc/caqti/Caqti_connection_sig/index.html

Module Caqti_connection_sig

Signature of connection handles.

You can obtain a connection handle from Caqti_lwt or Caqti_async, which both implement the Caqti_connect_sig interface.

While Caqti_request.t objects hold SQL code to be sent to the database, connection handles defined here provide the means to execute them with actual parameters on an RDBMS. So, there is a separation between preparation and execution. This is motivated by the common support for prepared queries in database client libraries, and by the desire to keep the possibly deeply nested data-processing code uncluttered by strings of SQL code. For this separation to be reasonably safe, the request declares the types of parameters and result, and these type declarations are placed right next to the SQL code, so that we can rely on OCaml's powers of refactoring large code bases safely.

The result type of Caqti_request.t only describes how to decode individual rows, leaving the decision of how to process multiple rows to the execution interface. That is, the request does not detail how to fold over rows, and for this reason, the separation into request constructors and executors entails a collection of pairwise compatible convenience functions across multiplicities between the APIs. E.g. when there are like-named Caqti_request.find_opt and S.find_opt functions, the first declares the row multiplicity, while the latter implements a way to fold rows into an OCaml datatype for that multiplicity.

Though a request object stipulates the expected multiplicity, there is still choice left for how to fold rows. E.g., a request constructed by Caqti_request.collect, or in fact any request, can be processed with S.fold, S.fold_s, S.iter_s, or S.collect_list. The two functions Caqti_request.create and S.fold can construct and process any supported SQL query.

module type Base = sig ... end

Essential connection signature implemented by drivers.

module type Convenience = sig ... end
module type Populate = sig ... end
module type S = sig ... end

Full connection signature available to users.

OCaml

Innovation. Community. Security.