Skip to content

Commit

Permalink
[AIRFLOW-941] Use defined parameters for psycopg2
Browse files Browse the repository at this point in the history
This works around
psycopg/psycopg2#517 .

Closes apache#2126 from bolkedebruin/AIRFLOW-941
  • Loading branch information
bolkedebruin committed Mar 6, 2017
1 parent 2cfe282 commit e79dee8
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions airflow/hooks/postgres_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,17 @@ def get_conn(self):
conn = self.get_connection(self.postgres_conn_id)
conn_args = dict(
host=conn.host,
user=conn.login,
password=conn.password,
dbname=self.schema or conn.schema,
port=conn.port)
dbname=self.schema or conn.schema)
# work around for https://github.com/psycopg/psycopg2/issues/517
# todo: remove when psycopg2 2.7.1 is released
# https://issues.apache.org/jira/browse/AIRFLOW-945
if conn.port:
conn_args['port'] = conn.port
if conn.login:
conn_args['user'] = conn.login
if conn.password:
conn_args['password'] = conn.password

# check for ssl parameters in conn.extra
for arg_name, arg_val in conn.extra_dejson.items():
if arg_name in ['sslmode', 'sslcert', 'sslkey', 'sslrootcert', 'sslcrl', 'application_name']:
Expand Down

0 comments on commit e79dee8

Please sign in to comment.