package pgx_unix
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=7c2f6dc86e2ad75b6119281b8db4509d60dce12d4c9de3d8fa7ccd43aa61c273
md5=b659449513e1b70b7a67a954d115d246
doc/pgx_unix/Pgx_unix/Prepared/index.html
Module Pgx_unix.Prepared
val sexp_of_s : s -> Ppx_sexp_conv_lib.Sexp.t
prepare ?name ?types conn ~query
prepares the statement query
and sets the parameter types to types
. If no name
is given, a random name will be generated. If no types are given, then the PostgreSQL engine infers types.
close_statement t
closes a prepared statement and frees up any resources.
val with_prepare :
?name:string ->
?types:Pgx.oid list ->
t ->
query:string ->
f:(s -> 'a monad) ->
'a monad
prepare
a query, execute f
, and then close_statement
execute conn ~params t
executes the given prepared statement, with the given parameters params
, returning the result rows (if any).
There are several steps involved at the protocol layer: (1) a "portal" is created from the statement, binding the parameters in the statement (Bind). (2) the portal is executed (Execute). (3) we synchronise the connection (Sync).
The optional ?portal
parameter may be used to name the portal created in step (1) above (otherwise the unnamed portal is used). This is only important if you want to call describe_portal
to find out the result types.
val describe :
s ->
(Pgx.params_description * Pgx.Result_desc.t list option) monad
describe_statement t
describes the statement's parameter types and result types.
close_portal conn ?portal ()
closes a portal and frees up any resources.
val describe_portal :
?portal:string ->
s ->
Pgx.Result_desc.t list option monad
describe_portal conn ?portal ()
describes the named or unnamed portal's result types.