Coverage for airflow.hooks.jdbc_hook : 55%
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
|
""" General hook for jdbc db access.
If a connection id is specified, host, port, schema, username and password will be taken from the predefined connection. Raises an airflow error if the given connection id doesn't exist. Otherwise host, port, schema, username and password can be specified on the fly.
:param jdbc_url: jdbc connection url :type jdbc_url: string :param jdbc_driver_name: jdbc driver name :type jdbc_driver_name: string :param jdbc_driver_loc: path to jdbc driver :type jdbc_driver_loc: string :param conn_id: reference to a predefined database :type conn_id: string :param sql: the sql code to be executed :type sql: string or string pointing to a template file. File must have a '.sql' extensions. """
conn = self.get_connection(getattr(self, self.conn_name_attr)) host = conn.host login = conn.login psw = conn.password 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,) return conn
""" Enable or disable autocommit for the given connection :param conn: The connection :return: """ conn.jconn.autocommit = autocommit |