sqlalchemy: pymysql Connection.ping AttributeError
Describe the bug
sqlalchemy with PyMySQL 0.9.3 ping cause exception.
Optional link from https://docs.sqlalchemy.org which documents the behavior that is expected
No response
SQLAlchemy Version in Use
2.0.23 1.4.50
DBAPI (i.e. the database driver)
pymysql
Database Vendor and Major Version
MySQL 8
Python Version
3.9
Operating system
Linux
To Reproduce
from sqlalchemy import create_engine
from sqlalchemy import text
SQLALCHEMY_DATABASE_URI='mysql+pymysql://xxxx:xxxx@xxxx:3306/mysql'
engine = create_engine(SQLALCHEMY_DATABASE_URI, pool_pre_ping=True, pool_size=1)
def test():
with engine.connect() as conn:
conn.execute(text("select user from mysql.user limit 1"))
for _ in range(2):
test()
Error
Traceback (most recent call last):
File "/workspace/test-env/../greatrds/.vscode/test.py", line 13, in <module>
test()
File "/workspace/test-env/../greatrds/.vscode/test.py", line 9, in test
with engine.connect() as conn:
File "/workspace/test-env/venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 3268, in connect
return self._connection_cls(self)
File "/workspace/test-env/venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 145, in __init__
self._dbapi_connection = engine.raw_connection()
File "/workspace/test-env/venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 3292, in raw_connection
return self.pool.connect()
File "/workspace/test-env/venv/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 452, in connect
return _ConnectionFairy._checkout(self)
File "/workspace/test-env/venv/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 1378, in _checkout
del fairy
File "/workspace/test-env/venv/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__
raise exc_value.with_traceback(exc_tb)
File "/workspace/test-env/venv/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 1306, in _checkout
result = pool._dialect._do_ping_w_event(
File "/workspace/test-env/venv/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 709, in _do_ping_w_event
return self.do_ping(dbapi_connection)
File "/workspace/test-env/venv/lib/python3.9/site-packages/sqlalchemy/dialects/mysql/pymysql.py", line 104, in do_ping
if self._send_false_to_ping:
File "/workspace/test-env/venv/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py", line 1146, in __get__
obj.__dict__[self.__name__] = result = self.fget(obj)
File "/workspace/test-env/venv/lib/python3.9/site-packages/sqlalchemy/dialects/mysql/pymysql.py", line 93, in _send_false_to_ping
insp = langhelpers.get_callable_argspec(Connection.ping)
AttributeError: 'function' object has no attribute 'ping'
Additional context
Package Version
greenlet 3.0.1 pip 21.2.4 PyMySQL 0.9.3 setuptools 58.1.0 SQLAlchemy 1.4.50
About this issue
- Original URL
- State: closed
- Created 7 months ago
- Comments: 20 (15 by maintainers)
Commits related to this issue
- Fix pre-ping regression in old PyMySQL versions. Fixed regression introduced by the fix in ticket :ticket:`10492` when using pool pre-ping with PyMySQL version older than 1.0. Fixes: #10650 Change-I... — committed to sqlalchemy/sqlalchemy by CaselIT 7 months ago
- Fix pre-ping regression in old PyMySQL versions. Fixed regression introduced by the fix in ticket :ticket:`10492` when using pool pre-ping with PyMySQL version older than 1.0. Fixes: #10650 Change-I... — committed to sqlalchemy/sqlalchemy by CaselIT 7 months ago
- Fix pre-ping regression in old PyMySQL versions. Fixed regression introduced by the fix in ticket :ticket:`10492` when using pool pre-ping with PyMySQL version older than 1.0. Fixes: #10650 Change-I... — committed to jenstroeger/sqlalchemy by CaselIT 7 months ago
this can be a 1.4 backport assuming 1.4.49 did not have this problem. It looked like the issue was old pymysql didn’t have “ping” at all, but if it’s local to the 1.4.50 change, then we can backport, but it might not be released