Repository: incubator-airflow Updated Branches: refs/heads/master 2cfe28244 -> e79dee871
[AIRFLOW-941] Use defined parameters for psycopg2 This works around https://github.com/psycopg/psycopg2/issues/517 . Closes #2126 from bolkedebruin/AIRFLOW-941 Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/e79dee87 Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/e79dee87 Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/e79dee87 Branch: refs/heads/master Commit: e79dee8718ca7d69a6905509f45fd2c5e9267209 Parents: 2cfe282 Author: Bolke de Bruin <bo...@xs4all.nl> Authored: Mon Mar 6 21:03:14 2017 +0100 Committer: Bolke de Bruin <bo...@xs4all.nl> Committed: Mon Mar 6 21:03:14 2017 +0100 ---------------------------------------------------------------------- airflow/hooks/postgres_hook.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/e79dee87/airflow/hooks/postgres_hook.py ---------------------------------------------------------------------- diff --git a/airflow/hooks/postgres_hook.py b/airflow/hooks/postgres_hook.py index 372e4e5..4b460c1 100644 --- a/airflow/hooks/postgres_hook.py +++ b/airflow/hooks/postgres_hook.py @@ -36,10 +36,17 @@ class PostgresHook(DbApiHook): 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']: