Module Postgresql
Client-interface to the PostgreSQL database.
Types
module FFormat : sig ... end
Type of field formats
type ftype
=
Type of fields
module Error_field : sig ... end
module Error_code : sig ... end
type result_status
=
Status of command/query results
type put_copy_result
=
|
Put_copy_queued
Data queued
|
Put_copy_not_queued
Data not queued due to full bufffers (async only)
|
Put_copy_error
Copying failed, see
#error_message
for detailsResult of put_copy_data and put_copy_end
type get_copy_result
=
Result of get_copy_data
type getline_result
=
|
EOF
End of input reached
|
LineRead
Entire line has been read
|
BufFull
Buffer full but terminating newline not encountered
Result of getline
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
|
Cancel_failure of string
Kinds of exceptions:
Field_out_of_range (i, n)
- access to fieldi
not within rangen
Tuple_out_of_range (i, n)
- access to tuplei
not within rangen
Binary
- result consists of binary tuple dataConnection_failure msg
- connection failed due to reasonmsg
Unexpected_status (stat, msg, expected)
- result statusstat
was not inexpected
due to errormsg
exception
Error of error
Error error
indicates anerror
val string_of_error : error -> string
string_of_error error
converterror
to a human-readable message
exception
Oid of oid
Oid oid
conversion from an oid to an ftype encountered an unknownoid
Utility functions
val unescape_bytea : string -> string
unescape_bytea str
unescapes binary stringstr
. This function supports the new hex format for encoding bytea strings (introduced in Postgresql 9.0) even if the local libpq library is from an older version.
val string_of_ftype : ftype -> string
string_of_ftype ftype
convertsftype
to a string.
val ftype_of_string : string -> ftype
string_of_ftype ftype
converts string to aftype
.
Handling results of commands and queries
val result_status : result_status -> string
result_status stat
convert statusstat
to a human-readable message
val invalid_oid : oid
invalid_oid
invalid Oid.
Query parameters
val null : string
null
can be used as an element of the optional argumentparameters
passed to theexec
orsend_query
method to indicate a NULL value.
class type result = object ... end
Class type of query results.
Handling database connections
type connection_status
=
|
Ok
|
Bad
|
Connection_started
|
Connection_made
|
Connection_awaiting_response
|
Connection_auth_ok
|
Connection_setenv
|
Connection_ssl_startup
Status of a connection
type polling_status
=
|
Polling_failed
|
Polling_reading
|
Polling_writing
|
Polling_ok
Polling status used while establishing a connection asynchronously.
type flush_status
=
|
Successful
|
Data_left_to_send
Result of a call to flush on nonblocking connections.
type conninfo_option
=
{
}
Record of connection options
module Notification : sig ... end
Type of asynchronous notifications
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 -> ?startonly:bool -> unit -> object ... end
Class of connections.