fix(mysql): fallback to pymysql when MySQLdb is not installed in get_datatype() (#39729)

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Daniel Vaz Gaspar
2026-04-29 14:40:39 +01:00
committed by GitHub
parent 54f1e32763
commit c7c9a17d6b
2 changed files with 45 additions and 1 deletions

View File

@@ -402,7 +402,10 @@ class MySQLEngineSpec(BasicParametersMixin, BaseEngineSpec):
if not cls.type_code_map:
# only import and store if needed at least once
# pylint: disable=import-outside-toplevel
import MySQLdb
try:
import MySQLdb
except ImportError:
import pymysql as MySQLdb # type: ignore[import-untyped] # noqa: N812
ft = MySQLdb.constants.FIELD_TYPE
cls.type_code_map = {