module Postgresql: sig
.. end
Client-interface to the PostgreSQL database.
Please learn about more details in the database documentation!
Types
type
oid = int
Object ID (= Postgresql type of an object)
type
large_object
Handle for large objects
module FFormat: sig
.. end
Type of field formats
type
ftype =
| |
BOOL |
| |
BYTEA |
| |
CHAR |
| |
NAME |
| |
INT8 |
| |
INT2 |
| |
INT2VECTOR |
| |
INT4 |
| |
REGPROC |
| |
TEXT |
| |
OID |
| |
TID |
| |
XID |
| |
CID |
| |
OIDVECTOR |
| |
POINT |
| |
LSEG |
| |
PATH |
| |
BOX |
| |
POLYGON |
| |
LINE |
| |
FLOAT4 |
| |
FLOAT8 |
| |
ABSTIME |
| |
RELTIME |
| |
TINTERVAL |
| |
UNKNOWN |
| |
CIRCLE |
| |
CASH |
| |
MACADDR |
| |
INET |
| |
CIDR |
| |
ACLITEM |
| |
BPCHAR |
| |
VARCHAR |
| |
DATE |
| |
TIME |
| |
TIMESTAMP |
| |
TIMESTAMPTZ |
| |
INTERVAL |
| |
TIMETZ |
| |
BIT |
| |
VARBIT |
| |
NUMERIC |
| |
REFCURSOR |
| |
REGPROCEDURE |
| |
REGOPER |
| |
REGOPERATOR |
| |
REGCLASS |
| |
REGTYPE |
| |
RECORD |
| |
CSTRING |
| |
ANY |
| |
ANYARRAY |
| |
VOID |
| |
TRIGGER |
| |
LANGUAGE_HANDLER |
| |
INTERNAL |
| |
OPAQUE |
| |
ANYELEMENT |
Type of fields
type
result_status =
| |
Empty_query |
| |
Command_ok |
| |
Tuples_ok |
| |
Copy_out |
| |
Copy_in |
| |
Bad_response |
| |
Nonfatal_error |
| |
Fatal_error |
Status of command/query results
type
getline_result =
| |
EOF |
| |
LineRead |
| |
BufFull |
Result of getline
type
getline_async_result =
| |
EndOfData |
| |
NoData |
| |
DataRead of int |
| |
PartDataRead of int |
Result of getline_async
type
seek_cmd =
| |
SEEK_SET |
| |
SEEK_CUR |
| |
SEEK_END |
Seek command ("whence")
Exceptions and error handling
type
error =
| |
Field_out_of_range of int * int |
| |
Tuple_out_of_range of int * int |
| |
Binary |
| |
Connection_failure of string |
| |
Unexpected_status of result_status * string * result_status list |
Kinds of exceptions:
Field_out_of_range (i, n)
- access to field i
not within range n
Tuple_out_of_range (i, n)
- access to tuple i
not within range n
Binary
- result consists of binary tuple data
Connection_failure msg
- connection failed due to reason msg
Unexpected_status (stat, msg, expected)
- result status stat
was not in
expected
due to error msg
exception Error of error
Error error
indicates an error
val string_of_error : error -> string
string_of_error error
convert error
to a human-readable message
exception Oid of oid
Oid oid
conversion from an oid to an ftype encountered an unknown oid
Utility functions
val escape_string : ?pos:int -> ?len:int -> string -> string
escape_string pos len str
escapes ASCII-substring str
of length
len
starting at position pos
for use within SQL.
pos
: default = 0
len
: default = String.length str - pos
val unescape_bytea : string -> string
unescape_bytea str
unescapes binary string str
.
val ftype_of_oid : oid -> ftype
ftype_of_oid oid
converts oid
to an ftype
.
val oid_of_ftype : ftype -> oid
oid_of_ftype ftype
converts ftype
to an oid
.
val string_of_ftype : ftype -> string
string_of_ftype ftype
converts ftype
to a string.
val ftype_of_string : string -> ftype
string_of_ftype ftype
converts ftype
to a string.
Handling results of commands and queries
val result_status : result_status -> string
result_status stat
convert status stat
to a human-readable message
val invalid_oid : oid
invalid_oid
invalid Oid.
class type result = object
.. end
Class type of query results.
Handling database connections
type
connection_status =
Status of a connection
type
conninfo_option = {
|
cio_keyword : string ; |
|
cio_envvar : string ; |
|
cio_compiled : string option ; |
|
cio_val : string option ; |
|
cio_label : string ; |
|
cio_dispchar : string ; |
|
cio_dispsize : int ; |
}
Record of connection options
val conndefaults : unit -> conninfo_option array
conndefaults ()
Returns array of all records of type conninfo_option
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
Class of connections.