Fix MySQL metadata database failing when only PyMySQL is installed - #71251
Open
1fanwang wants to merge 1 commit into
Open
Fix MySQL metadata database failing when only PyMySQL is installed#712511fanwang wants to merge 1 commit into
1fanwang wants to merge 1 commit into
Conversation
1fanwang
marked this pull request as ready for review
August 6, 2026 18:00
configure_adapters() raised a RuntimeError telling the user to install mysqlclient whenever mysqlclient was absent, even though PyMySQL was present and is configured a few lines below. The RuntimeError was raised inside a try block that only catches ImportError, so it escaped instead of falling through to the PyMySQL branch as the surrounding code intended. Signed-off-by: 1fanwang <1fannnw@gmail.com>
1fanwang
force-pushed
the
mysql-pymysql-driver-fix
branch
from
August 6, 2026 18:12
73e1a47 to
d27a95e
Compare
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
related: #70235
configure_adapters()raises aRuntimeErrortelling the user to installmysqlclientwhenevermysqlclientis absent — even when PyMySQL is installedand is the driver named in the connection string. The error is raised inside a
trythat only catchesImportError, so it escapes instead of falling throughto the PyMySQL branch a few lines below, which the surrounding code clearly
intends as the alternative:
So
mysql+pymysql://fails duringimport airflow, before any command runs. Thedocs recommend
mysqlclientand note it is the only driver covered by CI, butthey also point users at the SQLAlchemy MySQL dialect page if they want a
different one, so hard-failing here is not intended.
Each driver is now configured independently, and the error is raised only when
neither is importable — the condition the message actually describes.
#70235 fixes a separate PyMySQL failure further along the same path (dynamic
PREPARE/EXECUTESQL in migration0017_2_9_2). That one blocks a migration;this one blocks
import airflow. The two do not overlap.Testing Done
Raw logs
Before, PyMySQL installed,
mysqlclientabsent:After, same environment:
followed by a real DAG run on that database:
With neither driver installed, the error still fires and now names both:
Was generative AI tooling used to co-author this PR?
Generated-by: GitHub Copilot CLI (Claude Opus 5) following the guidelines