airflow.providers.odbc.hooks.odbc

This module contains ODBC hook.

Module Contents

Classes

OdbcHook

Interact with odbc data sources using pyodbc.

class airflow.providers.odbc.hooks.odbc.OdbcHook(*args, database=None, driver=None, dsn=None, connect_kwargs=None, sqlalchemy_scheme=None, **kwargs)[source]

Bases: airflow.hooks.dbapi.DbApiHook

Interact with odbc data sources using pyodbc.

See ODBC Connection for full documentation.

DEFAULT_SQLALCHEMY_SCHEME = mssql+pyodbc[source]
conn_name_attr = odbc_conn_id[source]
default_conn_name = odbc_default[source]
conn_type = odbc[source]
hook_name = ODBC[source]
supports_autocommit = True[source]
property connection(self)[source]

airflow.Connection object with connection id odbc_conn_id

property database(self)[source]

Database provided in init if exists; otherwise, schema from Connection object.

property sqlalchemy_scheme(self)[source]

Database provided in init if exists; otherwise, schema from Connection object.

property connection_extra_lower(self)[source]

connection.extra_dejson but where keys are converted to lower case.

This is used internally for case-insensitive access of odbc params.

property driver(self)[source]

Driver from init param if given; else try to find one in connection extra.

property dsn(self)[source]

DSN from init param if given; else try to find one in connection extra.

property odbc_connection_string(self)[source]

ODBC connection string We build connection string instead of using pyodbc.connect params because, for example, there is no param representing ApplicationIntent=ReadOnly. Any key-value pairs provided in Connection.extra will be added to the connection string.

property connect_kwargs(self)[source]

Returns effective kwargs to be passed to pyodbc.connect after merging between conn extra, connect_kwargs and hook init.

Hook connect_kwargs precedes connect_kwargs from conn extra.

If attrs_before provided, keys and values are converted to int, as required by pyodbc.

get_conn(self)[source]

Returns a pyodbc connection object.

get_uri(self)[source]

URI invoked in get_sqlalchemy_engine() method

get_sqlalchemy_connection(self, connect_kwargs=None, engine_kwargs=None)[source]

Sqlalchemy connection object

Was this entry helpful?