airflow.providers.jdbc.hooks.jdbc
¶
Module Contents¶
Classes¶
General hook for JDBC access. |
- class airflow.providers.jdbc.hooks.jdbc.JdbcHook(*args, driver_path=None, driver_class=None, **kwargs)[source]¶
Bases:
airflow.providers.common.sql.hooks.sql.DbApiHook
General hook for JDBC access.
JDBC URL, username and password will be taken from the predefined connection. Note that the whole JDBC URL must be specified in the “host” field in the DB. Raises an airflow error if the given connection id doesn’t exist.
- To configure driver parameters, you can use the following methods:
Supply them as constructor arguments when instantiating the hook.
Set the “driver_path” and/or “driver_class” parameters in the “hook_params” dictionary when creating the hook using SQL operators.
Set the “driver_path” and/or “driver_class” extra in the connection and correspondingly enable the “allow_driver_path_in_extra” and/or “allow_driver_class_in_extra” options in the “providers.jdbc” section of the Airflow configuration. If you’re enabling these options in Airflow configuration, you should make sure that you trust the users who can edit connections in the UI to not use it maliciously.
Patch the
JdbcHook.default_driver_path
and/orJdbcHook.default_driver_class
values in the “local_settings.py” file.
See JDBC connection for full documentation.
- Parameters
- property connection_extra_lower: dict[source]¶
connection.extra_dejson
but where keys are converted to lower case.This is used internally for case-insensitive access of jdbc params.
- set_autocommit(conn, autocommit)[source]¶
Set autocommit for the given connection.
- Parameters
conn (jaydebeapi.Connection) – The connection.
autocommit (bool) – The connection’s autocommit setting.
- get_autocommit(conn)[source]¶
Get autocommit setting for the provided connection.
- Parameters
conn (jaydebeapi.Connection) – Connection to get autocommit setting from.
- Returns
connection autocommit setting. True if
autocommit
is set to True on the connection. False if it is either not set, set to False, or the connection does not support auto-commit.- Return type