package caqti-miou
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=036380a0f1a67e09d002cc47f2cb1c52ebf4f7cc9b89ea5b70cec3b389ce298d
sha512=8d8e12e6101bb9b61b805e68236375f685c63400fefe3de422a24990e16b16ef2eeaebc66171b8dbe498be3e3d394445ee49c9a93b5b0b3e9d9d43b9fcf1acdc
doc/caqti-miou.unix/Caqti_miou_unix/index.html
Module Caqti_miou_unixSource
Establishing connections using miou.unix.
This library considered unstable for now, and may be revised or replaced as the effect-based libraries evolve.
include Caqti_connect_sig.S
with type 'a fiber := 'a
and type ('a, 'e) stream := ('a, 'e) Caqti_miou.Stream.t
and type ('a, 'e) pool := ('a, 'e) Pool.t
and type connection := Caqti_miou.connection
and type 'a with_switch := sw:Caqti_miou.Switch.t -> 'a
and type 'a with_stdenv := 'a
val connect :
?subst:(Caqti_template.Dialect.t -> Caqti_template.Query.subst) ->
?env:(Caqti_driver_info.t -> string -> Caqti_query.t) ->
?config:Caqti_connect_config.t ->
?tweaks_version:(int * int) ->
sw:Caqti_miou.Switch.t ->
Uri.t ->
(Caqti_miou.connection, [> Caqti_error.load_or_connect ]) resultconnect uri locates and loads a driver which can handle uri, passes uri to the driver, which establish a connection and returns a first-class module implementing Caqti_connection_sig.S.
connect uri connects to the database at uri and returns a first class module implementing Caqti_connection_sig.S for the given database system. In case of preemptive threading, the connection must only be used from the thread where it was created.
The correct driver for the database system is inferred from the schema of uri; see the respective drivers for the supported schemas and related URI syntax. A driver can either be linked in to the application or, if supported, dynamically linked using the caqti.plugin package.
val with_connection :
?subst:(Caqti_template.Dialect.t -> Caqti_template.Query.subst) ->
?env:(Caqti_driver_info.t -> string -> Caqti_query.t) ->
?config:Caqti_connect_config.t ->
?tweaks_version:(int * int) ->
Uri.t ->
(Caqti_miou.connection ->
('a, [> Caqti_error.load_or_connect ] as 'e) result) ->
('a, 'e) resultval connect_pool :
?pool_config:Caqti_pool_config.t ->
?post_connect:(Caqti_miou.connection -> (unit, 'connect_error) result) ->
?subst:(Caqti_template.Dialect.t -> Caqti_template.Query.subst) ->
?env:(Caqti_driver_info.t -> string -> Caqti_query.t) ->
?config:Caqti_connect_config.t ->
?tweaks_version:(int * int) ->
sw:Caqti_miou.Switch.t ->
Uri.t ->
((Caqti_miou.connection, [> Caqti_error.connect ] as 'connect_error) Pool.t,
[> Caqti_error.load ])
resultconnect_pool uri is a pool of database connections constructed by connect uri.
Do not use pooling for connections to volatile resources like sqlite3::memory: and beware of temporary tables or other objects which may not be shared across connections to the same URI.
If you use preemptive threading, note that the connection pool must only be used from the thread where it was created. Use thread local storage to create a separate pool per thread if necessary.