Skip to content

Commit f2c2664

Browse files
authored
fix(mysql): catch PyMySQL OperationalError exception (#7919)
## Description of changes When trying to connect to a mySQL backend, the following error can appear: ``` OperationalError: (pymysql.err.OperationalError) (1298, "Unknown or incorrect time zone: 'UTC'") (Background on this error at: https://sqlalche.me/e/20/e3q8) ``` This is due to an exception generated by PyMySQL. The exception, formerly generated by SQLAlchemy was already caught by Ibis since #6010, this PR adds a catching of the PyMySQL exception. ## Issues closed Resolves #7918
1 parent dc1ffad commit f2c2664

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

ibis/backends/mysql/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import warnings
66
from typing import TYPE_CHECKING, Literal
77

8+
import pymysql
89
import sqlalchemy as sa
910
from sqlalchemy.dialects import mysql
1011

@@ -112,7 +113,7 @@ def connect(dbapi_connection, connection_record):
112113
with dbapi_connection.cursor() as cur:
113114
try:
114115
cur.execute("SET @@session.time_zone = 'UTC'")
115-
except sa.exc.OperationalError:
116+
except (sa.exc.OperationalError, pymysql.err.OperationalError):
116117
warnings.warn("Unable to set session timezone to UTC.")
117118

118119
super().do_connect(engine)

0 commit comments

Comments
 (0)