Skip to content

Commit d702496

Browse files
authored
fix: support MySQL v9 (#713)
1 parent 7946565 commit d702496

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

aws_advanced_python_wrapper/mysql_driver_dialect.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,18 @@ def get_connection_from_obj(self, obj: object) -> Any:
131131

132132
if isinstance(obj, CMySQLCursor):
133133
try:
134-
if isinstance(obj._cnx, CMySQLConnection) or isinstance(obj._cnx, MySQLConnection):
135-
return obj._cnx
134+
conn = None
135+
136+
if hasattr(obj, '_cnx'):
137+
conn = obj._cnx
138+
elif hasattr(obj, '_connection'):
139+
conn = obj._connection
140+
if conn is None:
141+
return None
142+
143+
if isinstance(conn, CMySQLConnection) or isinstance(conn, MySQLConnection):
144+
return conn
145+
136146
except ReferenceError:
137147
return None
138148

0 commit comments

Comments
 (0)