Skip to content

Commit 8aef431

Browse files
committed
Fix typing error and handling of undefined unicode
1 parent 4a50979 commit 8aef431

File tree

1 file changed

+7
-2
lines changed
  • providers/mysql/src/airflow/providers/mysql/hooks

1 file changed

+7
-2
lines changed

providers/mysql/src/airflow/providers/mysql/hooks/mysql.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@
3030
logger = logging.getLogger(__name__)
3131

3232
if TYPE_CHECKING:
33-
from airflow.models import Connection
33+
from airflow.providers.mysql.version_compat import AIRFLOW_V_3_0_PLUS
34+
35+
if AIRFLOW_V_3_0_PLUS:
36+
from airflow.models import Connection
37+
else:
38+
from airflow.models.connection import Connection
3439

3540
try:
3641
from mysql.connector.abstracts import MySQLConnectionAbstract
@@ -130,7 +135,7 @@ def _get_conn_config_mysql_client(self, conn: Connection) -> dict:
130135

131136
if conn.extra_dejson.get("charset", False):
132137
conn_config["charset"] = conn.extra_dejson["charset"]
133-
if conn_config["charset"].lower() in ("utf8", "utf-8"):
138+
if conn_config.get("charset", "undef").lower() in ("utf8", "utf-8"):
134139
conn_config["use_unicode"] = True
135140
if conn.extra_dejson.get("cursor", False):
136141
try:

0 commit comments

Comments
 (0)