The Apache Airflow Microsoft MSSQL Provider enables seamless interaction with Microsoft SQL Server databases within Airflow DAGs. It provides hooks and operators for connecting to, querying, and managing data in MSSQL. This provider is part of the larger Apache Airflow ecosystem, currently at version 4.5.1, and receives updates aligned with Airflow's release cycle, as well as independent bug fixes and feature enhancements.
pip install apache-airflow-providers-microsoft-mssqlVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates a simple Airflow DAG that uses the `MsSqlOperator` to connect to a Microsoft SQL Server database and execute a basic SQL query. Before running, ensure you have an Airflow connection named `mssql_default` configured with the appropriate host, credentials, and optional driver settings in your Airflow UI or via CLI.
Upgrade your Python environment to 3.10 or newer. If unable to upgrade Python, pin the provider version to `<4.0.0` (e.g., `apache-airflow-providers-microsoft-mssql<4.0.0`).
Choose your preferred driver: `pip install pymssql` OR `pip install pyodbc`. If using `pyodbc`, ensure the appropriate ODBC driver (e.g., 'ODBC Driver 17 for SQL Server') is installed and configured on the Airflow worker's operating system. Configure your Airflow connection's 'Extra' field to specify the driver, e.g., `{"driver": "ODBC Driver 17 for SQL Server"}`.Carefully review MSSQL connection documentation for your specific SQL Server version and driver. Experiment with 'Extra' parameters like `{"driver": "{ODBC Driver 17 for SQL Server}", "autocommit": true, "Encrypt": "yes", "TrustServerCertificate": "yes"}`. Test the connection outside of Airflow using a simple Python script with your chosen driver to isolate connection issues.pip install apache-airflow-providers-microsoft-mssql
pip install apache-airflow-providers-microsoft-mssql
pip install apache-airflow-providers-microsoft-mssql
Double-check all connection parameters (Host, Port, Login, Password, Schema) in the Airflow UI. Ensure the MSSQL server is accessible from where Airflow is running and that firewall rules permit the connection. Also, verify that the `pymssql` library (which `MsSqlHook` uses by default) is correctly installed and compatible with your MSSQL server version.
Install the appropriate Microsoft ODBC Driver for SQL Server on your system. For Linux environments, this typically involves adding Microsoft's package repositories and installing `msodbcsql17` (or newer) and `unixodbc-dev`. Ensure the driver is correctly referenced in your connection string if using `OdbcHook` or custom `pyodbc` connections.