module type PGOCAML_GENERIC =sig..end
type 'a t
type 'a monad
typeisolation =[ `Read_committed | `Read_uncommitted | `Repeatable_read | `Serializable ]
typeaccess =[ `Read_only | `Read_write ]
exception Error of string
exception PostgreSQL_Error of string * (char * string) list
http://www.postgresql.org/docs/8.1/static/protocol-error-fields.htmlval connect : ?host:string ->
?port:int ->
?user:string ->
?password:string ->
?database:string ->
?unix_domain_socket_dir:string ->
unit ->
'a t monad$PGDATABASE, etc. environment
variables are available.val close : 'a t ->
unit monadval ping : 'a t ->
unit monadval begin_work : ?isolation:isolation ->
?access:access ->
?deferrable:bool ->
'a t ->
unit monadval commit : 'a t ->
unit monadval rollback : 'a t ->
unit monadval serial : 'a t ->
string -> int64 monadSELECT CURRVAL(serial). For a table
called table with serial column id you would typically
call this as serial dbh "table_id_seq" after the previous INSERT
operation to get the serial number of the inserted row.val serial4 : 'a t ->
string -> int32 monadPGOCaml_generic.PGOCAML_GENERIC.serial but assumes that the column is a SERIAL or
SERIAL4 type.val serial8 : 'a t ->
string -> int64 monad
val max_message_length : int Pervasives.refSys.max_string_length, which means that we will try to read as
much data from the back-end as we can, and this may cause us to
run out of memory (particularly on 64 bit machines), causing a
possible denial of service. You may want to set this to a smaller
size to avoid this happening.val verbose : int Pervasives.refstderr.
Default verbosity level is 1.val set_private_data : 'a t -> 'a -> unit
NB. The pa_pgsql camlp4 extension uses this for its own purposes, which
means that in most programs you will not be able to attach private data
to the database handle.
val private_data : 'a t -> 'aNot_found.
NB. The pa_pgsql camlp4 extension uses this for its own purposes, which
means that in most programs you will not be able to attach private data
to the database handle.
typepa_pg_data =(string, bool) Hashtbl.t
PGOCaml.pa_pg_data PGOCaml.ttypeoid =int32
typeparam =string option
typeresult =string option
typerow =result list
val prepare : 'a t ->
query:string ->
?name:string ->
?types:oid list ->
unit -> unit monadprepare conn ~query ?name ?types () prepares the statement query
and optionally names it name and sets the parameter types to types.
If no name is given, then the "unnamed" statement is overwritten. If
no types are given, then the PostgreSQL engine infers types.
Synchronously checks for errors.val execute_rev : 'a t ->
?name:string ->
?portal:string ->
params:param list ->
unit ->
row list
monadval execute : 'a t ->
?name:string ->
?portal:string ->
params:param list ->
unit ->
row list
monadexecute conn ?name ~params () executes the named or unnamed
statement name, 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 PGOCaml_generic.PGOCAML_GENERIC.describe_portal
to find out the result types.
val cursor : 'a t ->
?name:string ->
?portal:string ->
params:param list ->
(row ->
unit monad) ->
unit monadval close_statement : 'a t ->
?name:string -> unit -> unit monadclose_statement conn ?name () closes a prepared statement and frees
up any resources.val close_portal : 'a t ->
?portal:string -> unit -> unit monadclose_portal conn ?portal () closes a portal and frees up any resources.typerow_description =result_description list
type result_description = {
|
name : |
(* | Field name. | *) |
|
table : |
(* | OID of table. | *) |
|
column : |
(* | Column number of field in table. | *) |
|
field_type : |
(* | The type of the field. | *) |
|
length : |
(* | Length of the field. | *) |
|
modifier : |
(* | Type modifier. | *) |
typeparams_description =param_description list
type param_description = {
|
param_type : |
(* | The type of the parameter. | *) |
val describe_statement : 'a t ->
?name:string ->
unit ->
(params_description *
row_description option)
monaddescribe_statement conn ?name () describes the named or unnamed
statement's parameter types and result types.val describe_portal : 'a t ->
?portal:string ->
unit ->
row_description option
monaddescribe_portal conn ?portal () describes the named or unnamed
portal's result types.val name_of_type : ?modifier:int32 -> oid -> stringoid.
For instance, name_of_type (Int32.of_int 23) returns "int32" because
the OID for PostgreSQL's internal int4 type is 23. As another
example, name_of_type (Int32.of_int 25) returns "string".typeinet =Unix.inet_addr * int
typetimestamptz =CalendarLib.Calendar.t * CalendarLib.Time_Zone.t
typeint16 =int
typebytea =string
typepoint =float * float
typehstore =(string * string option) list
typebool_array =bool array
typeint32_array =int32 array
typeint64_array =int64 array
typestring_array =string array
typefloat_array =float array
val string_of_oid : oid -> stringval string_of_bool : bool -> stringval string_of_int : int -> stringval string_of_int16 : int16 -> stringval string_of_int32 : int32 -> stringval string_of_int64 : int64 -> stringval string_of_float : float -> stringval string_of_point : point -> stringval string_of_hstore : hstore -> stringval string_of_inet : inet -> stringval string_of_timestamp : CalendarLib.Calendar.t -> stringval string_of_timestamptz : timestamptz -> stringval string_of_date : CalendarLib.Date.t -> stringval string_of_time : CalendarLib.Time.t -> stringval string_of_interval : CalendarLib.Calendar.Period.t -> stringval string_of_bytea : bytea -> stringval string_of_string : string -> stringval string_of_unit : unit -> stringval string_of_bool_array : bool_array -> stringval string_of_int32_array : int32_array -> stringval string_of_int64_array : int64_array -> stringval string_of_string_array : string_array -> stringval string_of_float_array : float_array -> stringval oid_of_string : string -> oidval bool_of_string : string -> boolval int_of_string : string -> intval int16_of_string : string -> int16val int32_of_string : string -> int32val int64_of_string : string -> int64val float_of_string : string -> floatval point_of_string : string -> pointval hstore_of_string : string -> hstoreval inet_of_string : string -> inetval timestamp_of_string : string -> CalendarLib.Calendar.tval timestamptz_of_string : string -> timestamptzval date_of_string : string -> CalendarLib.Date.tval time_of_string : string -> CalendarLib.Time.tval interval_of_string : string -> CalendarLib.Calendar.Period.tval bytea_of_string : string -> byteaval unit_of_string : string -> unitval bool_array_of_string : string -> bool_arrayval int32_array_of_string : string -> int32_arrayval int64_array_of_string : string -> int64_arrayval string_array_of_string : string -> string_arrayval float_array_of_string : string -> float_arrayval bind : 'a monad ->
('a -> 'b monad) ->
'b monadval return : 'a -> 'a monad