[33/45] incubator-airflow git commit: [AIRFLOW-941] Use defined parameters for psycopg2

2017-03-12 Thread bolke
[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/1f3aead5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/1f3aead5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/1f3aead5

Branch: refs/heads/v1-8-stable
Commit: 1f3aead5c486c3576a5df3b6904aa449b8a1d90a
Parents: 4077c6d
Author: Bolke de Bruin 
Authored: Mon Mar 6 21:03:14 2017 +0100
Committer: Bolke de Bruin 
Committed: Sun Mar 12 08:28:48 2017 -0700

--
 airflow/hooks/postgres_hook.py | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/1f3aead5/airflow/hooks/postgres_hook.py
--
diff --git a/airflow/hooks/postgres_hook.py b/airflow/hooks/postgres_hook.py
index 75c8226..750ebbb 100644
--- a/airflow/hooks/postgres_hook.py
+++ b/airflow/hooks/postgres_hook.py
@@ -32,10 +32,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=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']:



incubator-airflow git commit: [AIRFLOW-941] Use defined parameters for psycopg2

2017-03-06 Thread bolke
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 
Authored: Mon Mar 6 21:03:14 2017 +0100
Committer: Bolke de Bruin 
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']: