forked from smarkets/epgsql_connpool
-
Notifications
You must be signed in to change notification settings - Fork 1
Pool application for epgsql
License
tholschuh/epgsql_connpool
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Erlang PostgreSQL Database Client Pool for epgsql Configure application env like so: application:start(epgsql), application:set_env(epgsql_connpool, pools, [ {maindb, [ {host, "127.0.0.1"}, {username, "postgres"}, {password, ""}, {size, 10}, {opts, [ {timeout, 5000}, {database, "my_database"} ]} ] } ] ), application:start(epgsql_connpool). And to make queries: {atomic, NumRows} = epgsql_connpool:transaction( maindb, fun(Db) -> Sql = "SELECT count(*) FROM my_table WHERE id = $1;" {ok, _, [{Ret}]} = pgsql:equery(Db, Sql, [123]), Ret end). With transaction(), all queries made within the fun are surrounded by a BEGIN/COMMIT/ROLLBACK. With dirty(), the statements are run as-is, not in a transaction.
About
Pool application for epgsql
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published
Languages
- Erlang 100.0%