Authors: Tristan Sloughter (t@crashfast.com).
Postgres driver and pool for Erlang.
This module provides functions for interacting with a pool and querying the database.decode_fun() = fun((row(), fields()) -> row()) | undefined
decode_option() = return_rows_as_maps | {return_rows_as_maps, boolean()} | column_name_as_atom | {column_name_as_atom, boolean()} | {decode_fun, decode_fun()}
error() = {pgo_error, #{error_field() => binary()}}
error_field() = severity | code | message | detail | hint | position | internal_position | internal_query | where | file | line | routine | schema | table | column | data_type | constraint | {unknown, byte()}
fields() = [#row_description_field{name = iodata(), table_oid = oid(), attr_number = integer(), data_type_oid = oid(), data_type_size = integer(), type_modifier = integer(), format = pgsql_format()}]
oid() = pos_integer()
options() = #{pool => atom(), trace => boolean(), queue => boolean(), decode_opts => [decode_option()]}
pgsql_format() = text | binary
pool() = atom()
pool_config() = #{host => string(), port => integer(), user => string(), password => string(), database => string(), pool_size => integer(), queue_target => integer(), queue_interval => integer(), idle_interval => integer(), queue => boolean(), trace => boolean(), decode_opts => [decode_option()]}
pool_option() = queue | {queue, boolean()}
result() = #{command := atom(), num_rows := integer(), rows := list()} | {error, error()} | {error, any()}
row() = list() | map()
break/1 | Disconnects the socket held by this reference. |
checkin/2 | Return a checked out connection to its pool. |
checkout/1 | Returns a connection from the pool. |
checkout/2 | |
query/1 | Equivalent to query(Query, [], #{}). |
query/2 | Equivalent to query(Query, Params, #{}). |
query/3 | Executes an extended query either on a Pool or a provided connection. |
start_pool/2 | Starts connection pool as a child of pgo_sup. |
transaction/1 | Equivalent to transaction(default, Fun, []). |
transaction/2 | Equivalent to transaction(default, Fun, Options). |
transaction/3 | Runs a function, passing it a connection, in a SQL transaction. |
with_conn/2 |
break(Conn::pgo_pool:conn()) -> ok
Disconnects the socket held by this reference.
checkin(Ref::pgo_pool:pool_ref(), Conn::pgo_pool:conn()) -> ok
Return a checked out connection to its pool
checkout(Pool::atom()) -> {ok, pgo_pool:pool_ref(), pgo_pool:conn()} | {error, any()}
Returns a connection from the pool.
checkout(Pool::atom(), Options::[pool_option()]) -> {ok, pgo_pool:pool_ref(), pgo_pool:conn()} | {error, any()}
query(Query::iodata()) -> result()
Equivalent to query(Query, [], #{}).
query(Query::iodata(), Params::list()) -> result()
Equivalent to query(Query, Params, #{}).
Executes an extended query either on a Pool or a provided connection.
start_pool(Name::pool(), PoolConfig::pool_config()) -> {ok, pid()}
Starts connection pool as a child of pgo_sup.
transaction(Fun::fun(() -> any())) -> any() | {error, any()}
Equivalent to transaction(default, Fun, []).
transaction(Fun::fun(() -> any()), Options::options()) -> any() | {error, any()}
Equivalent to transaction(default, Fun, Options).
Runs a function, passing it a connection, in a SQL transaction.
with_conn(Conn, Fun) -> any()
Generated by EDoc