class connection :?host:string -> ?hostaddr:string -> ?port:string -> ?dbname:string -> ?user:string -> ?password:string -> ?options:string -> ?tty:string -> ?requiressl:string -> ?conninfo:string -> unit ->object..end
When conninfo is given, it will be used instead of all other
optional arguments.
method finish : unit#finish closes the connection.Error if there is a connection error.method try_reset : unit#try_reset tries to reset the connection if it is bad. If
resetting fails, the error exception will be raised with
Connection_failure.Error if there is a connection error.method reset : unit#reset resets the connection.Error if there is a connection error.method notifies : (string * int) option#notifiesError if there is a connection error.Some (name, pid) if available (None
otherwise), where name is the name the of relation containing
data, pid the process id of the backend.method set_notice_processor : (string -> unit) -> unit#set_notice_processor controls reporting of notice and warning
messages generated by a connection.Error if there is a connection error.method db : string#dbError if there is a connection error.method user : string#userError if there is a connection error.method pass : string#passError if there is a connection error.method host : string#hostError if there is a connection error.method port : string#portError if there is a connection error.method tty : string#ttyError if there is a connection error.method options : string#optionsError if there is a connection error.method status : connection_status#statusError if there is a connection error.method error_message : string#error_messageError if there is a connection error.method backend_pid : int#backendError if there is a connection error.method empty_result : result_status -> resultempty_result statError if there is a connection error.stat.method exec : ?expect:result_status list ->
?params:string array ->
?binary_params:bool array -> string -> resultexec ?expect ?params ?binary_params query synchronous execution
of query or command query. The result status will be checked
against all elements in expect. If expect is not empty and if
there is no match, the exception Unexpected_status will be raised.
Additional query parameters can be passed in the params array.
They must not be escaped and they can be referred to in query
as $1, $2, ... The value null can be used in the params
array to denote an SQL NULL. It is possible to specify that some
of the query parameters are passed as binary strings using the
binary_params array.
If no (or an empty) query parameter is passed, it is possible to
emit several commands with a single call.
Raises
Error if there is a connection error.Error if there is an unexpected result status.expect : default = []params : default = ||binary_params : default = ||method prepare : string -> string -> resultprepare stm_name query creates a prepared query named stm_name
which will execute the query or command query when passed to
#exec_prepared.method exec_prepared : ?expect:result_status list ->
?params:string array ->
?binary_params:bool array -> string -> resultexec_prepared ?expect ?params ?binary_params stm_name acts as
#exec, except executes the prepared query stm_name.method describe_prepared : string -> result#describe_prepared stm_name submits a request to obtain
information about the specified prepared statement, and waits for
completion. Postgresql.connection.describe_prepared allows an application to obtain
information about a previously prepared statement. The stm_name
parameter can be the empty string ("") to reference the unnamed
statement, otherwise it must be the name of an existing prepared
statement. On success, a Postgresql.result with status Command_ok is
returned. The methods Postgresql.result.nparams and Postgresql.result.paramtype
of the class result can be used to obtain information about
the parameters of the prepared statement, and the methods
Postgresql.result.nfields, Postgresql.result.fname and Postgresql.result.ftype provide
information about the result columns (if any) of the statement.
To prepare a statement use the SQL command PREPARE.
Raises Error if there is a connection error.
See also PostgreSQL documentation about PREPARE
method send_query : ?params:string array -> ?binary_params:bool array -> string -> unitsend_query ?params ?binary_params query asynchronous execution
of query or command query.
Additional query parameters can be passed in the params array.
They must not be escaped and they can be referred to in query
as $1, $2, ... The value null can be used in the params
array to denote an SQL NULL. It is possible to specify that some
of the query parameters are passed as binary strings using the
binary_params array.
If no (or an empty) query parameter is passed, it is possible to
emit several commands with a single call.
Raises Error if there is a connection error.
params : default = ||binary_params : default = ||method get_result : result optionget_resultError if there is a connection error.Some result of an asynchronous query if
available or None.method getline : ?pos:int -> ?len:int -> string -> getline_resultgetline ?pos ?len buf reads a newline-terminated line of at most
len characters into buf starting at position pos.Invalid_argument if the buffer parameters are invalid.Error if there is a connection error.pos : default = 0len : default = String.length buf - posmethod getline_async : ?pos:int -> ?len:int -> string -> getline_async_resultgetline_async ?pos ?len buf reads a newline-terminated line of
at most len characters into buf starting at position pos
(asynchronously). No need to call endcopy after receiving
EndOfData.Invalid_argument if the buffer parameters are invalid.Error if there is a connection error.pos : default = 0len : default = String.length buf - posmethod putline : string -> unitputline str sends str to backend server. Don't use this method
for binary data, use putnbytes instead!Error if there is a connection error.method putnbytes : ?pos:int -> ?len:int -> string -> unitputnbytes ?pos ?len buf sends the substring of buf of length
len starting at pos to backend server (use this method for
binary data).Invalid_argument if the buffer parameters are invalid.Error if there is a connection error.pos : default = 0len : default = String.length buf - posmethod endcopy : unitendcopy synchronizes with the backend.Error if there is a connection error.method copy_out : (string -> unit) -> unitcopy_out f applies f to each line returned by backend server.Error if there is a connection error.method copy_out_channel : Pervasives.out_channel -> unitcopy_out_channel ch sends each line returned by backend server
to output channel ch.Error if there is a connection error.method copy_in_channel : Pervasives.in_channel -> unitcopy_in_channel ch sends each line in input channel ch to
backend server.Error if there is a connection error.method set_nonblocking : bool -> unitset_nonblocking b sets state of the connection to nonblocking if
b is true and to blocking otherwise.Error if there is a connection error.method is_nonblocking : boolis_nonblockingError if there is a connection error.method consume_input : unitconsume_input consume any available input from backend.Error if there is a connection error.method is_busy : boolis_busyError if there is a connection error.method flush : unitflush attempts to flush any data queued to the backend.Error if there is a connection error.method socket : intsocket obtains the file descriptor for the backend connection
socket as an integer.Error if there is a connection error.method request_cancel : unitrequest_cancel requests that PostgreSQL abandon processing of
the current command.Error if there is a connection or cancel error.method lo_creat : oidlo_creat creates a new large object and returns its oid.Error if there is a connection error.method lo_import : string -> oidlo_import filename imports an operating system file given by
filename as a large object.Error if there is a connection error.method lo_export : oid -> string -> unitlo_export oid filename exports the large object given by oid
to an operating system file given by filename.Error if there is a connection error.method lo_open : oid -> large_objectlo_open oid opens the large object given by oid for reading and
writing.Error if there is a connection error.method lo_write : ?pos:int -> ?len:int -> string -> large_object -> unitlo_write ?pos ?len buf lo writes len bytes of buffer buf
starting at position pos to large object lo.Invalid_argument if the buffer parameters are invalid.Error if len bytes could not be written.Error if there is a connection error.pos : default = 0len : default = String.length buf - posmethod lo_write_ba : ?pos:int ->
?len:int ->
(char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t ->
large_object -> unitlo_write, but performs a zero-copy write from the given Bigarray.method lo_read : large_object -> ?pos:int -> ?len:int -> string -> intlo_read lo ?pos ?len buf reads len bytes from large object lo
to buffer buf starting at position pos.Invalid_argument if the buffer parameters are invalid.Error if len bytes could not be read.Error if there is a connection error.pos : default = 0len : default = String.length buf - posmethod lo_read_ba : large_object ->
?pos:int ->
?len:int ->
(char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t ->
intlo_read, but performs a zero-copy read into the given Bigarray.method lo_seek : ?pos:int -> ?whence:seek_cmd -> large_object -> unitlo_seek ?pos ?whence lo seeks read/write position pos in
large object lo relative to the start, current read/write
position, or end of the object (whence is SEEK_SET, SEEK_CUR,
SEEK_END respectively).Error if there is a connection error.pos : default = 0whence : default = SEEK_SETmethod lo_tell : large_object -> intlo_tell loError if there is a connection error.lo.method lo_close : large_object -> unitlo_close lo closes large object lo.Error if there is a connection error.method lo_unlink : oid -> unitlo_unlink oid removes the large object specified by oid from the
database.Error if there is a connection error.method escape_string : ?pos:int -> ?len:int -> string -> stringescape_string ?pos ?len str escapes ASCII-substring str
of length len starting at position pos for use within SQL.pos : default = 0len : default = String.length str - posmethod escape_bytea : ?pos:int -> ?len:int -> string -> stringescape_bytea ?pos ?len str escapes binary substring str
of length len starting at position pos for use within SQL.pos : default = 0len : default = String.length str - pos