blob: 839407bb294b4c480d7d167e688c809d210c5d71 [file] [log] [blame]
:py:mod:`airflow.providers.odbc.hooks.odbc`
===========================================
.. py:module:: airflow.providers.odbc.hooks.odbc
.. autoapi-nested-parse::
This module contains ODBC hook.
Module Contents
---------------
Classes
~~~~~~~
.. autoapisummary::
airflow.providers.odbc.hooks.odbc.OdbcHook
.. py:class:: OdbcHook(*args, database = None, driver = None, dsn = None, connect_kwargs = None, sqlalchemy_scheme = None, **kwargs)
Bases: :py:obj:`airflow.hooks.dbapi.DbApiHook`
Interact with odbc data sources using pyodbc.
See :doc:`/connections/odbc` for full documentation.
.. py:attribute:: DEFAULT_SQLALCHEMY_SCHEME
:annotation: = mssql+pyodbc
.. py:attribute:: conn_name_attr
:annotation: = odbc_conn_id
.. py:attribute:: default_conn_name
:annotation: = odbc_default
.. py:attribute:: conn_type
:annotation: = odbc
.. py:attribute:: hook_name
:annotation: = ODBC
.. py:attribute:: supports_autocommit
:annotation: = True
.. py:method:: connection(self)
:property:
``airflow.Connection`` object with connection id ``odbc_conn_id``
.. py:method:: database(self)
:property:
Database provided in init if exists; otherwise, ``schema`` from ``Connection`` object.
.. py:method:: sqlalchemy_scheme(self)
:property:
Database provided in init if exists; otherwise, ``schema`` from ``Connection`` object.
.. py:method:: connection_extra_lower(self)
:property:
``connection.extra_dejson`` but where keys are converted to lower case.
This is used internally for case-insensitive access of odbc params.
.. py:method:: driver(self)
:property:
Driver from init param if given; else try to find one in connection extra.
.. py:method:: dsn(self)
:property:
DSN from init param if given; else try to find one in connection extra.
.. py:method:: odbc_connection_string(self)
:property:
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.
.. py:method:: connect_kwargs(self)
:property:
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.
.. py:method:: get_conn(self)
Returns a pyodbc connection object.
.. py:method:: get_uri(self)
URI invoked in :py:meth:`~airflow.hooks.dbapi.DbApiHook.get_sqlalchemy_engine` method
.. py:method:: get_sqlalchemy_connection(self, connect_kwargs = None, engine_kwargs = None)
Sqlalchemy connection object