airbnb / omniduct

A toolkit providing a uniform interface for connecting to and extracting data from a wide variety of (potentially remote) data stores (including HDFS, Hive, Presto, MySQL, etc).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Some case in connecting postgresql

kination opened this issue · comments

Hello.
This is the bug(I'm not sure it is...) while working on some test case with connecting postgresql. I refered the sample in README, so I'm not sure it has been implemented well.

duct_registry = DuctRegistry()
sql_alchemy_client = duct_registry.new(names='ps_duct', protocol='postgresql', host='localhost', port=5432)
sql_alchemy_client.query('CREATE DATABASE ps_duct_local')

This causes issue sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) FATAL: role "_mysql" does not exist, but it was bit weird so I found out some more in database uri.

When connecting via sqlalchemy, uri for create_engine shows as postgresql://_mysql@localhost:5432/. It looks like it needs account info for access.

Am I doing something wrong?
Thanks.

Hey @djKooks

I'm not immeditately sure where the _mysql is coming from but you can pass in your desired username and password

In [28]: client = registry.new(names='ps_duct', protocol='postgresql', host='localhost', username='dan', password='SUPERSECRET', port=5432, database='mydb')

In [29]: client.db_uri
Out[29]: 'postgresql://dan:SUPERSECRET@localhost:5432/mydb'