Skip to content
Snippets Groups Projects
Commit 2456fdc1 authored by Wojciech Barcik's avatar Wojciech Barcik Committed by Jason Salyers
Browse files

Handle postgres connection string with unix socket, fix #100

parent 0b08a974
No related branches found
No related tags found
2 merge requests!456Release candidate v1 24,!370Jsalyers muting at sql level
...@@ -38,13 +38,20 @@ class Db: ...@@ -38,13 +38,20 @@ class Db:
async def init(self, url): async def init(self, url):
"""Initialize the aiopg.sa engine.""" """Initialize the aiopg.sa engine."""
conf = make_url(url) conf = make_url(url)
self.db = await create_engine(user=conf.username, dsn = {}
database=conf.database, if conf.username:
password=conf.password, dsn['user'] = conf.username
host=conf.host, if conf.database:
port=conf.port, dsn['database'] = conf.database
maxsize=20, if conf.password:
**conf.query) 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): def close(self):
"""Close pool.""" """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