mirror https://github.com/epgsql/epgsql

Will ba47564c3f initial import of epgsql 16 лет назад
ebin ba47564c3f initial import of epgsql 16 лет назад
include ba47564c3f initial import of epgsql 16 лет назад
src ba47564c3f initial import of epgsql 16 лет назад
test_ebin ba47564c3f initial import of epgsql 16 лет назад
test_src ba47564c3f initial import of epgsql 16 лет назад
.hgignore ba47564c3f initial import of epgsql 16 лет назад
LICENSE ba47564c3f initial import of epgsql 16 лет назад
Makefile ba47564c3f initial import of epgsql 16 лет назад
README ba47564c3f initial import of epgsql 16 лет назад

README

Erlang PostgreSQL Database Client

* Connect

{ok, C} = pgsql:connect(Host, [Username, Password, Opts]).

Opts is a property list. The following properties are supported:

- database
- port

ok = pgsql:close(C).

* Simple Query

{ok, Columns, Rows} = pgsql:squery(C, Sql).

Columns - list of column records, see pgsql.hrl for definition.
Rows - list of tuples, one for each row.

The simple query protocol returns all columns as text (Erlang binaries)
and does not support binding parameters.

* Extended Query

{ok, Columns, Rows} = pgsql:equery(C, Sql, [Parameters]).

Parameters - list of values to be bound to $1, $2, $3, etc.

The extended query protocol combines parse, bind, and execute using
the unnamed prepared statement and portal. PostgreSQL's binary format
is used to return integers as Erlang integers, floats as floats,
bytea/text/varchar columns as binaries, bools as true/false, etc.
For details see pgsql_binary.erl.

* Parse/Bind/Execute

{ok, Statement} = pgsql:parse(C, [StatementName], Sql, [ParameterTypes]).

StatementName - optional, reusable, name for the prepared statement.
ParameterTypes - optional list of PostgreSQL types for each parameter.

For valid type names see pgsql_types.erl.

ok = pgsql:bind(C, Statement, [PortalName], ParameterValues).

PortalName- optional name for the result portal.

{ok | partial, Rows} = pgsql:execute(C, Statement, [PortalName], [MaxRows]).

PortalName - optional portal name used in bind/4.
MaxRows - maximum number of rows to return (0 for all rows).

execute returns {partial, Rows} when more rows are available.

ok = pgsql:close(C, Statement).
ok = pgsql:close(C, statement | portal, Name).
ok = pgsql:sync(C).