Registry / workflow / apache-airflow-providers-mysql

apache-airflow-providers-mysql

JSON →
library6.6.2pypypiunverified

The Apache Airflow MySQL Provider enables seamless interaction with MySQL databases within Airflow DAGs. It offers operators and hooks to execute SQL queries, transfer data, and manage connections. As part of the Airflow ecosystem, it receives regular updates, with the current version being 6.5.1, requiring Python >= 3.10.

pip install apache-airflow-providers-mysql
INSTALL
IMPORT
SIG · APACHE-AIRFLOW-PRO
A
apache-airflow-providers-mysql
workflowpythonv6.6.2
Install
Import
Disk
Pass rate
0/ 10
Env Coverage0 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v? · pip install
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.95 runs
build_error
glibc
py 3.103.95 runs
build_error
Code
Verified usage

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

MySqlHook
from airflow.providers.mysql.hooks.mysql import MySqlHook
SQLExecuteQueryOperator
from airflow.providers.common.sql.operators.sql import SQLExecuteQueryOperator
from airflow.providers.mysql.operators.mysql import MySqlOperator
`MySqlOperator` was removed in provider versions 6.3.2+; use `SQLExecuteQueryOperator` from the `common.sql` provider instead.
MySqlToS3Operator
from airflow.providers.mysql.operators.mysql import MySqlToS3Operator

This quickstart demonstrates how to use `SQLExecuteQueryOperator` to interact with a MySQL database. It creates a table, inserts data, and then selects it. Ensure you have a MySQL connection named `mysql_default` configured in your Airflow UI.

from __future__ import annotations import pendulum from airflow.models.dag import DAG from airflow.providers.common.sql.operators.sql import SQLExecuteQueryOperator # Ensure you have a MySQL connection named 'mysql_default' configured in Airflow UI # Host: localhost, Schema: airflow_db, User: airflow, Pass: airflow with DAG( dag_id="mysql_quickstart_dag", start_date=pendulum.datetime(2023, 1, 1, tz="UTC"), catchup=False, schedule=None, tags=["mysql", "example"], ) as dag: create_table = SQLExecuteQueryOperator( task_id="create_test_table", conn_id="mysql_default", sql=""" CREATE TABLE IF NOT EXISTS test_table ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255) ); """, ) insert_data = SQLExecuteQueryOperator( task_id="insert_test_data", conn_id="mysql_default", sql="INSERT INTO test_table (name) VALUES ('Airflow User 1'), ('Airflow User 2');", ) select_data = SQLExecuteQueryOperator( task_id="select_test_data", conn_id="mysql_default", sql="SELECT * FROM test_table;", ) create_table >> insert_data >> select_data
Debug
Known issues
breakingThe `MySqlOperator` was removed from the provider package. Users should migrate to `SQLExecuteQueryOperator` from `airflow.providers.common.sql.operators.sql` for executing SQL queries. This change was introduced in provider versions 6.3.2 and later.
fix
Replace `MySqlOperator` imports and usages with `SQLExecuteQueryOperator`. The `conn_id` and `sql` parameters remain the same, and schema can be passed via `hook_params={'schema': '<database>'}`.
affects: >=6.3.2
breakingOlder versions of the MySQL provider (e.g., 2.x and above) require Apache Airflow version 2.1.0+ due to the removal of the `apply_default` decorator. Provider version 3.0.0+ specifically requires Airflow 2.2.0+. Installing an incompatible provider version may lead to automatic Airflow upgrades and require manual database migration.
fix
Ensure your Airflow installation meets the minimum version requirement for the MySQL provider you intend to install. Upgrade Airflow if necessary before installing the provider.
affects: <6.x (for Airflow 2.1+ compatibility); <3.0.0 (for Airflow 2.2+ compatibility)
gotchaAttempting to import MySQL-related components like `MySqlOperator` or `MySqlHook` without explicitly installing `apache-airflow-providers-mysql` will result in a `ModuleNotFoundError`.
fix
Always install the provider package using `pip install apache-airflow-providers-mysql` in your Airflow environment.
affects: All versions
gotchaInstallation of the `mysqlclient` dependency can fail if required system-level development packages (e.g., `libmysqlclient-dev` on Debian/Ubuntu) are not present, leading to build errors.
fix
Before installing the Python package, install the necessary system-level development headers for MySQL. For Debian/Ubuntu, use `sudo apt-get install default-libmysqlclient-dev`.
affects: All versions
gotchaUsers have reported `AttributeError: property 'connection' of 'MySqlHook' object has no setter` when `apache-airflow-providers-mysql` has no upper version constraint on `apache-airflow-providers-common-sql`, leading to incompatible versions being installed.
fix
Ensure that `apache-airflow-providers-common-sql` is constrained to a compatible version or upgrade `apache-airflow-providers-mysql` to its latest version, which usually resolves such conflicts.
affects: Certain combinations with `apache-airflow-providers-common-sql <1.17.0` (e.g., `apache-airflow-providers-mysql 5.6.1` with `apache-airflow-providers-common-sql 1.17.0`)
gotchaLong-running MySQL connections via Airflow can experience 'Server has gone away' errors, typically due to the MySQL server restarting or connection timeouts.
fix
For persistent connections, consider enabling connection pooling with recycling. Adjust MySQL server's `wait_timeout` and `interactive_timeout` parameters if applicable.
affects: All versions
Upgrade
Version history
6.6.2latest on PyPI · released Aug 23, 2026
Audit
Dependencies
apache-airflowrequiredCore Airflow functionality; provider versions require specific Airflow versions (e.g., >=2.1.0, and >=2.2.0 for provider 3.0.0+).
mysqlclientrequiredCommon Python client for MySQL; installed as a dependency. Might require system-level development packages.
mysql-connector-pythonrequiredAlternative Python client for MySQL; installed as a dependency.
Agent activity
45 hits · last 30 days
node
40
OpenAI (training)
1
Resources
apache-airflow-providers-mysql — pip install apache-airflow-providers-mysql · libregistry