airflow.providers.odbc.hooks.odbc

This module contains ODBC hook.

Module Contents

class airflow.providers.odbc.hooks.odbc.OdbcHook(*args, database: Optional[str] = None, driver: Optional[str] = None, dsn: Optional[str] = None, connect_kwargs: Optional[dict] = None, sqlalchemy_scheme: Optional[str] = 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]
connection[source]

airflow.Connection object with connection id odbc_conn_id

database[source]

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

sqlalchemy_scheme[source]

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

connection_extra_lower[source]

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

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

driver[source]

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

dsn[source]

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

odbc_connection_string[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.

connect_kwargs[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: Optional[dict] = None, engine_kwargs: Optional[dict] = None)[source]

Sqlalchemy connection object

Was this entry helpful?