[
https://issues.apache.org/jira/browse/AIRFLOW-1083?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16676004#comment-16676004
]
ASF GitHub Bot commented on AIRFLOW-1083:
-----------------------------------------
fordguo closed pull request #2227: [AIRFLOW-1083] Fixes the connect error when
jaydebeapi >1.0 and the jdbc's autocommit bug
URL: https://github.com/apache/incubator-airflow/pull/2227
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/airflow/hooks/jdbc_hook.py b/airflow/hooks/jdbc_hook.py
index bc1f352ecc..4d51dd306c 100644
--- a/airflow/hooks/jdbc_hook.py
+++ b/airflow/hooks/jdbc_hook.py
@@ -44,6 +44,9 @@ class JdbcHook(DbApiHook):
default_conn_name = 'jdbc_default'
supports_autocommit = True
+ def is_jaydebeapi_v1(self):
+ return jaydebeapi.__version_info__[0] >= 1
+
def get_conn(self):
conn = self.get_connection(getattr(self, self.conn_name_attr))
host = conn.host
@@ -52,9 +55,15 @@ def get_conn(self):
jdbc_driver_loc = conn.extra_dejson.get('extra__jdbc__drv_path')
jdbc_driver_name = conn.extra_dejson.get('extra__jdbc__drv_clsname')
- conn = jaydebeapi.connect(jdbc_driver_name,
- [str(host), str(login), str(psw)],
- jdbc_driver_loc,)
+ if self.is_jaydebeapi_v1():
+ conn = jaydebeapi.connect(jdbc_driver_name,
+ str(host),
+ [str(login), str(psw)],
+ jdbc_driver_loc,)
+ else:
+ conn = jaydebeapi.connect(jdbc_driver_name,
+ [str(host), str(login), str(psw)],
+ jdbc_driver_loc,)
return conn
def set_autocommit(self, conn, autocommit):
@@ -64,4 +73,7 @@ def set_autocommit(self, conn, autocommit):
:param conn: The connection
:return:
"""
- conn.jconn.autocommit = autocommit
+ if self.is_jaydebeapi_v1():
+ conn.jconn.autoCommit = autocommit
+ else:
+ conn.jconn.autocommit = autocommit
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> after jaydebeapi >=1.0, use the connect(jclassname, url, driver_args...)
> ------------------------------------------------------------------------
>
> Key: AIRFLOW-1083
> URL: https://issues.apache.org/jira/browse/AIRFLOW-1083
> Project: Apache Airflow
> Issue Type: Bug
> Components: hooks
> Affects Versions: 1.8.0
> Reporter: Ford Guo
> Priority: Major
>
> I use the latest jaydebeapi 1.1.1, and dont get the correct connection with
> jdbc_hook
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)