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() = {dream_postgres_driver_error, #{error_field() => binary()}} | pg_types:encoding_error()
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(), type_info = tuple(), 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(), include_statement_span_attribute => boolean(), queue => boolean(), decode_opts => [decode_option()], pool_options => [pool_option()]}
pgsql_format() = text | binary
pool() = atom()
pool_config() = #{host => string(), port => integer(), user => string(), password => string() | fun(() -> iodata()), database => string(), application_name => atom() | iodata(), pool_size => integer(), queue_target => integer(), queue_interval => integer(), idle_interval => integer(), socket_options => [gen_tcp:connect_option()], queue => boolean(), trace => boolean(), decode_opts => [decode_option()], extra => term()} | [{atom(), string() | integer() | boolean()}]
pool_option() = queue | {queue, boolean()} | {timeout, timeout()} | {deadline, integer()}
result() = #{command := atom(), num_rows := non_neg_integer() | table, rows := [row()]} | {error, error()} | {error, any()}
row() = tuple() | 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 | |
| conn_extra/1 | Returns the extra value of the pool that the connection is from,
or undefined if the pool config has no extra. |
| format_error/1 | |
| 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. |
| query/4 | |
| start_pool/2 | Starts connection pool as a child of dream_postgres_driver_sup. |
| transaction/1 | Equivalent to transaction(dream_postgres_driver_default, Fun, #{}).
|
| transaction/2 | Equivalent to transaction(dream_postgres_driver_default, Fun, Options).
|
| transaction/3 | Runs a function, passing it a connection, in a SQL transaction. |
| with_conn/2 |
break(Conn::dream_postgres_driver_pool:conn()) -> ok
Disconnects the socket held by this reference.
checkin(Ref::dream_postgres_driver_pool:ref(), Conn::dream_postgres_driver_pool:conn()) -> ok
Return a checked out connection to its pool
checkout(Pool::atom()) -> {ok, dream_postgres_driver_pool:ref(), dream_postgres_driver_pool:conn()} | {error, any()}
Returns a connection from the pool.
checkout(Pool::atom(), Options::[pool_option()]) -> {ok, dream_postgres_driver_pool:ref(), dream_postgres_driver_pool:conn()} | {error, any()}
conn_extra(Conn::dream_postgres_driver_pool:conn()) -> term()
Returns the extra value of the pool that the connection is from,
or undefined if the pool config has no extra.
format_error(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.
query(Query, Params, Options, Conn) -> any()
start_pool(Name::pool(), PoolConfig::pool_config()) -> {ok, pid()}
Starts connection pool as a child of dream_postgres_driver_sup.
transaction(Fun::fun(() -> any())) -> any() | {error, any()}
Equivalent to transaction(dream_postgres_driver_default, Fun, #{}).
transaction(Fun::fun(() -> any()), Options::options()) -> any() | {error, any()}
Equivalent to transaction(dream_postgres_driver_default, Fun, Options).
Runs a function, passing it a connection, in a SQL transaction.
with_conn(Conn, Fun) -> any()
Generated by EDoc