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.providers.common.sql.hooks.sql.DbApiHook

Interact with odbc data sources using pyodbc.

See ODBC Connection for full documentation.

property connection[source]

airflow.Connection object with connection id odbc_conn_id

property database: str | None[source]

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

property sqlalchemy_scheme: str[source]

Sqlalchemy scheme either from constructor, connection extras or default.

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 odbc params.

property driver: str | None[source]

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

property dsn: str | None[source]

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

property 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.

property connect_kwargs: dict[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.

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]
get_conn()[source]

Returns a pyodbc connection object.

get_uri()[source]

URI invoked in get_sqlalchemy_engine() method.

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

Sqlalchemy connection object

Was this entry helpful?