Skip to content
Snippets Groups Projects
Commit 29508cf8 authored by Bartek Wrona's avatar Bartek Wrona
Browse files

Merge branch '100-enable-connecting-to-postgres-server-via-unix-socket' into 'develop'

Handle postgres connection string with unix socket, fix #100

See merge request !374
parents 06826c9d d868e239
No related branches found
No related tags found
2 merge requests!456Release candidate v1 24,!374Handle postgres connection string with unix socket, fix #100
......@@ -38,13 +38,20 @@ class Db:
async def init(self, url):
"""Initialize the aiopg.sa engine."""
conf = make_url(url)
self.db = await create_engine(user=conf.username,
database=conf.database,
password=conf.password,
host=conf.host,
port=conf.port,
maxsize=20,
**conf.query)
dsn = {}
if conf.username:
dsn['user'] = conf.username
if conf.database:
dsn['database'] = conf.database
if conf.password:
dsn['password'] = conf.password
if conf.host:
dsn['host'] = conf.host
if conf.port:
dsn['port'] = conf.port
if 'application_name' not in conf.query:
dsn['application_name'] = 'hive_server'
self.db = await create_engine(**dsn, maxsize=20, **conf.query)
def close(self):
"""Close pool."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment