Registry / database / apache-airflow-providers-odbc

apache-airflow-providers-odbc

JSON →
library4.12.3pypypi✓ verified 6d ago

This provider package enables Apache Airflow to connect to various ODBC data sources, including MS SQL Server, to execute queries and perform database operations. It is released independently from Airflow core and follows semantic versioning, with major version upgrades indicating breaking changes.

pip install apache-airflow-providers-odbc
INSTALL
IMPORT
SIG · APACHE-AIRFLOW-PRO
A
apache-airflow-providers-odbc
databasepythonv4.12.3
Install
24.1s avg
Import
Disk
259MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v4.12.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 261.2MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 24.1s · import 0.000s · 256MB
259MB installed
● package 259MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

OdbcHook
from airflow.providers.odbc.hooks.odbc import OdbcHook
OdbcOperator
from airflow.providers.odbc.operators.odbc import OdbcOperator
SQLExecuteQueryOperator
from airflow.providers.common.sql.operators.sql import SQLExecuteQueryOperator
As of provider version 3.1.0, SQL operators like SQLExecuteQueryOperator were moved to the common-sql provider.

This quickstart demonstrates a basic Airflow DAG using the `SQLExecuteQueryOperator` to interact with an ODBC database. It assumes an Airflow ODBC connection (`my_odbc_conn`) is configured in the UI or via environment variables, including the necessary ODBC driver. Remember to install system-level ODBC drivers for your specific database.

from __future__ import annotations import pendulum from airflow.models.dag import DAG from airflow.providers.common.sql.operators.sql import SQLExecuteQueryOperator # Ensure you have an Airflow Connection named 'my_odbc_conn' # type: ODBC # host: your_odbc_server # login: your_username # password: your_password # extra: {"driver": "{ODBC Driver 18 for SQL Server}", "autocommit": true} with DAG( dag_id="odbc_example_dag", start_date=pendulum.datetime(2023, 1, 1, tz="UTC"), schedule=None, catchup=False, tags=["odbc", "example"], ) as dag: create_table = SQLExecuteQueryOperator( task_id="create_table", sql=""" CREATE TABLE IF NOT EXISTS my_odbc_table ( id INT IDENTITY(1,1) PRIMARY KEY, value VARCHAR(255) ); """, conn_id="my_odbc_conn", ) insert_data = SQLExecuteQueryOperator( task_id="insert_data", sql=""" INSERT INTO my_odbc_table (value) VALUES ('test_value_{{ ds }}'); """, conn_id="my_odbc_conn", ) # Note: For fetching data, you'd typically use OdbcHook in a PythonOperator # or a custom operator, as SQLExecuteQueryOperator is for execution. create_table >> insert_data
Debug
Known issues
breakingThe `driver` parameter for `OdbcHook` must now be passed directly via the hook constructor or `hook_params` in SQL Operators, not through the connection's `extra` field, due to a security vulnerability fix.
fix
Update usage to pass `driver` as a keyword argument to `OdbcHook` or within the `hook_params` dictionary for SQL Operators. Example `extra` for connection: `{"autocommit": true}` and `driver='{ODBC Driver 18 for SQL Server}'` passed separately to the hook.
affects: Before 4.0.0
breakingThis provider version has increased minimum Airflow requirements. For example, provider `3.0.0` requires Airflow `2.2+` and provider `4.12.1` requires Airflow `2.11.0+`. Older provider versions had lower Airflow requirements.
fix
Ensure your Airflow core installation meets the minimum version requirement for the installed provider. Refer to the provider's changelog for specific version compatibility.
affects: From 2.0.0 onwards (specific to provider version)
breakingWhen passing keyword arguments to the ODBC connection via the `connect_kwargs` key in the connection's `extra` field (e.g., `autocommit`, `ansi`), values must now be booleans (e.g., `true`, `false`) instead of strings (`"true"`, `"false"`).
fix
Update your Airflow Connection's `extra` field to use boolean literals for `connect_kwargs` values: `"connect_kwargs": {"autocommit": true, "ansi": false}`.
affects: From 2.0.0 onwards
gotchaThe `apache-airflow-providers-odbc` package and its `pyodbc` dependency require system-level ODBC drivers to be installed on your Airflow worker machines. These are not installed by `pip`.
fix
Manually install the appropriate ODBC driver for your database (e.g., Microsoft ODBC Driver for SQL Server) on the operating system where Airflow workers run.
affects: All versions
gotchaEnabling the `allow_driver_in_extra` configuration (via `AIRFLOW__PROVIDERS_ODBC__ALLOW_DRIVER_IN_EXTRA=true` environment variable or `airflow.cfg`) is a security risk. It allows users to specify arbitrary ODBC drivers via the Airflow Connection's `extra` field, potentially leading to privilege escalation or arbitrary code execution if untrusted users can modify connections.
fix
Avoid setting `allow_driver_in_extra` to `True` unless you fully trust all users who can modify Airflow connections. Ensure drivers are only specified directly in DAG code or via the hook constructor.
affects: All versions
gotchaSome users have reported `UnicodeDecodeError` (e.g., `'utf-8' codec can't decode byte 0x91`) when using specific ODBC drivers (like Netezza) with certain Airflow and provider versions.
fix
If encountering encoding errors, ensure the correct character set is configured in your ODBC driver and/or connection string. Consult the specific database and ODBC driver documentation, or consider upgrading/downgrading provider/Airflow versions if a known fix exists.
affects: Specific combinations (e.g., Airflow 2.10.2, provider 4.7.0 with Netezza)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'airflow.providers.odbc'
The 'apache-airflow-providers-odbc' package is not installed.
fix
Install the package using 'pip install apache-airflow-providers-odbc'.
ImportError: cannot import name 'OdbcHook' from 'airflow.providers.odbc.hooks.odbc'
The 'OdbcHook' class is not available in the specified module, possibly due to an incorrect import path or missing package.
fix
Ensure that 'apache-airflow-providers-odbc' is installed and use the correct import statement: 'from airflow.providers.odbc.hooks.odbc import OdbcHook'.
pyodbc.Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')
The ODBC driver is not installed or the data source name (DSN) is not configured correctly.
fix
Install the appropriate ODBC driver for your database and ensure the DSN is correctly configured.
AttributeError: module 'pyodbc' has no attribute 'connect'
The 'pyodbc' module is not installed or is not accessible.
fix
Install the 'pyodbc' module using 'pip install pyodbc'.
OperationalError: ('08001', '[08001] [Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: Error code 0x2746 (10060) (SQLDriverConnect)')
The connection to the SQL Server timed out, possibly due to network issues or incorrect server address.
fix
Verify the server address, network connectivity, and that the SQL Server is configured to accept remote connections.
Upgrade
Version history
4.12.3latest on PyPI · released Jun 7, 2026
Audit
Dependencies
apache-airflowrequiredCore Airflow dependency. Provider version 4.12.1 requires Apache Airflow >=2.11.0.
pyodbcrequiredPython driver for ODBC connectivity. Included with 'apache-airflow[odbc]' extra, but also a direct dependency of the provider.
apache-airflow-providers-common-sqloptionalProvides common SQL functionalities. Can be installed with `pip install apache-airflow-providers-odbc[common.sql]`.
Agent activity
34 hits · last 30 days
node
30
Amazon
1
Resources
apache-airflow-providers-odbc — pip install apache-airflow-providers-odbc · libregistry