Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file caqti1_sigs.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229(* Copyright (C) 2014--2017 Petter A. Urkedal <paurkedal@gmail.com>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at your
* option) any later version, with the OCaml static compilation exception.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*)(** (v1) Signatures.
@deprecated Don't use this in new code. *)openCaqti1_describeopenCaqti1_query(** Parameter encoding functions. *)moduletypePARAM=sigtypet(** An abstract type for a query parameter. Only the backend knows the
actual type. *)valnull:t(** A designated value to replace a missing parameter. For SQL, [null] is
[NULL]. *)valoption:('a->t)->'aoption->t(** [option f None] is [null] and [option f (Some x)] is [f x]. *)valbool:bool->t(** Constructs a boolean parameter. If the database does not have booleans, an
integer value of 0 for false and 1 for true is used. *)valint:int->t(** Constructs an integer parameter. The remote end may have a different
range. For SQL, works with all integer types. *)valint32:int32->t(** Constructs an integer parameter. The remote end may have a different
range. For SQL, works with all integer types. *)valint64:int64->t(** Constructs an integer parameter. The remote end may have a different
range. For SQL, works with all integer types. *)valfloat:float->t(** Constructs a floating point parameter. Note that the precision in the
database may be different from that of the OCaml [float]. If conversion to
string is requried by the backend, this is done with the [%.*g] format
specifier, which may incur a small loss of precision, as well. *)valstring:string->t(** Given an UTF-8 encoded text, constructs a textual parameter with
backend-specific encoding. *)valbytes:bytes->t(** Constructs a parameter from an arbirary octet string. For SQL, the
parameter is compatible with the [BINARY] type. *)valdate_string:string->t(** Construct a date paramater from a string using ISO 8601 format. *)valdate_tuple:int*int*int->t(** Construct a date parameter from the year, month, and day of the month,
using the literal enumeration. I.e. Epoch is [(1970, 1, 1)]. *)valdate_cl:CalendarLib.Date.t->t(** Construct a parameter representing a date. *)valutc_float:float->t(** Construct a parameter representing date and time in the UTC time zone,
converted from a float representing the number of non-leap seconds passed
since 1970-01-01T00:00:00Z. *)valutc_string:string->t(** Create a parameter for an UTC timestamp field from a UTC time string in
ISO 8601 format. *)valutc_cl:CalendarLib.Calendar.t->t(** Construct a parameter representing an date and time in the UTC time
zone. *)end(** Tuple decoding functions.
These functions extracts and decodes components from a returned tuple.
The first argument is the index, starting from 0. The conversion
performed are the inverse of the same named functions of {!PARAM}, so the
documentation is not repeated here.
{b Note!} Calls to these functions are only valid during a callback
from one of the query execution functions. Returning a partial call or
embedding the call in a returned monad leads to undefined behaviour. *)moduletypeTUPLE=sigtypet(** An abstract type for a tuple passed by a backend to callbacks during
query execution. *)vallength:t->intvalis_null:int->t->boolvaloption:(int->t->'a)->int->t->'aoptionvalbool:int->t->boolvalint:int->t->intvalint32:int->t->int32valint64:int->t->int64valfloat:int->t->floatvalstring:int->t->stringvalbytes:int->t->bytesvaldate_string:int->t->stringvaldate_tuple:int->t->int*int*intvaldate_cl:int->t->CalendarLib.Date.tvalutc_float:int->t->floatvalutc_string:int->t->stringvalutc_cl:int->t->CalendarLib.Calendar.tend(** The main API as provided after connecting to a resource. *)moduletypeCONNECTION=sigmoduleParam:PARAM(** Interface for constructing query parameters. *)moduleTuple:TUPLE(** Interface for extracting result tuples. *)type'aio(** The IO monad for which the module is specialized. *)valuri:Uri.t(** The URI used to connect to the database. *)valdriver_info:Caqti_driver_info.t(** Information about the database driver which provides this connection. *)valdisconnect:unit->unitio(** Calling [disconnect ()] closes the connection to the database and frees
up related resources. *)valvalidate:unit->boolio(** For internal use by {!Caqti_pool}. Tries to ensure the validity of the
connection and must return [false] if unsuccessful. *)valcheck:(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. *)valdescribe:(query->querydescio)option(** 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]. *)(** {3 Querying} *)valexec:query->Param.tarray->unitio(** [exec q params] executes a query [q(params)] which is not expected to
return anything. *)valfind:query->(Tuple.t->'a)->Param.tarray->'aio(** [find_e q params] executes [q(params)] which is expected to return
exactly one tuple. *)valfind_opt:query->(Tuple.t->'a)->Param.tarray->'aoptionio(** [find q params] executes a query [q(params)] which is expected to return
at most one tuple. *)valfold:query->(Tuple.t->'a->'a)->Param.tarray->'a->'aio(** [fold q f params acc] executes [q(params)], composes [f] over the
resulting tuples in order, and applies the composition to [acc]. *)valfold_s:query->(Tuple.t->'a->'aio)->Param.tarray->'a->'aio(** [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]. *)valiter_p:query->(Tuple.t->unitio)->Param.tarray->unitio(** [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}. *)valiter_s:query->(Tuple.t->unitio)->Param.tarray->unitio(** [fold_s q f params] executes [q(params)] and calls [f t] sequentially in
the thread monad for each resulting tuple [t] in order. *)(** {3 Transactions} *)valstart:unit->unitio(** Starts a transaction if supported by the underlying database, otherwise
does nothing. *)valcommit:unit->unitio(** Commits the current transaction if supported by the underlying database,
otherwise does nothing. *)valrollback:unit->unitio(** Rolls back a transaction if supported by the underlying database,
otherwise does nothing. *)end(** The connect functions as exposed to application code through the
concurrency implementations:
- [Caqti_lwt] provided by caqti-lwt.
- [Caqti_async] provided by caqti-async. *)moduletypeCAQTI=sigtype'aiomodulePool:Caqti1_pool_sig.Swithtype'aio:='aio(** This is an instantiation of {!Caqti_pool} for the chosen thread monad. *)moduletypeCONNECTION=CONNECTIONwithtype'aio='aiovalconnect:Uri.t->(moduleCONNECTION)io(** Establish a single connection to a database. This must only be used by
one thread at a time, cooperative or not. *)valconnect_pool:?max_size:int->Uri.t->(moduleCONNECTION)Pool.t(** Create a pool of connections which can be shared among multiple
cooperative threads run from the main system thread. *)end