package postgresql
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=de42225cfcddb173352dcdeeba09594eae1c11c549480eef9fc623a3ca1b2e50
sha512=14875b271b85365c81a9a8fe614c50fe0205443cdd34e04cb1c727956f161cb310ac2acaf4790e8eace972e5c7d21a4bc7e39735d518f5a019410954f3ed62ba
doc/postgresql/Postgresql/index.html
Module Postgresql
Source
Client-interface to the PostgreSQL database.
Please learn about more details in the database documentation!
Types
Object ID (= Postgresql type of an object)
Handle for large objects
type ftype =
| BOOL
| BYTEA
| CHAR
| NAME
| INT8
| INT2
| INT2VECTOR
| INT4
| REGPROC
| TEXT
| OID
| TID
| XID
| CID
| OIDVECTOR
| JSON
| 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
| JSONB
Type of fields
type result_status =
| Empty_query
(*String sent to the backend was empty
*)| Command_ok
(*Successful completion of a command returning no data
*)| Tuples_ok
(*The query successfully executed
*)| Copy_out
(*Copy Out (from server) data transfer started
*)| Copy_in
(*Copy In (to server) data transfer started
*)| Bad_response
(*The server's response was not understood
*)| Nonfatal_error
| Fatal_error
| Copy_both
| Single_tuple
(*One tuple of a result set (
*)set_single_row_mode
)
Status of command/query results
Result of put_copy_data and put_copy_end
type get_copy_result =
| Get_copy_data of string
(*Data corresponding to one row is returned
*)| Get_copy_wait
(*The next row is still being received (async only); wait for read-only, call
*)consume_input
, and try again| Get_copy_end
(*All data has been successfully retrieved
*)| Get_copy_error
(*Copying failed, see
*)#error_message
for details
Result of get_copy_data
Result of getline
Result of getline_async
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
| Cancel_failure of string
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
string_of_error error
convert error
to a human-readable message
Utility functions
unescape_bytea str
unescapes binary string str
. 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.
Handling results of commands and queries
result_status stat
convert status stat
to a human-readable message
Query parameters
null
can be used as an element of the optional argument parameters
passed to the exec
or send_query
method to indicate a NULL value.
Handling database connections
Status of a connection
Polling status used while establishing a connection asynchronously.
Result of a call to flush on nonblocking connections.
type conninfo_option = {
cio_keyword : string;
(*Keyword of option
*)cio_envvar : string option;
(*Fallback environment variable name
*)cio_compiled : string option;
(*Fallback compiled in default value
*)cio_val : string option;
(*Current value of option, or NULL
*)cio_label : string;
(*Label for field in connect dialog
*)cio_dispchar : string;
(*Character to display for this field in dialog
*)cio_dispsize : int;
(*Field size in characters for dialog
*)
}
Record of connection options
Type of asynchronous notifications
conndefaults ()
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.