Closed
Description
Describe the bug
asyncmy dialect depends on pymysql, however it's not referenced at setup.cfg>
This leads to exception since the dialect implementation relies on it.
To Reproduce
Given the follow Pipfile:
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
sqlalchemy = { version = "==1.4.29", extras = ['asyncio', 'mypy']}
[packages]
sqlalchemy = { version = "==1.4.29", extras = ['asyncio', 'asyncmy'] }
[requires]
python_version = "3.9"
After create an AsyncEngine and try run any query it will fail:
from unittest import IsolatedAsyncioTestCase
from sqlalchemy.ext.asyncio import create_async_engine, AsyncEngine
class RepositoryCase(IsolatedAsyncioTestCase):
async def asyncSetUp(self):
await super().asyncSetUp()
self._engine: AsyncEngine = create_async_engine(
"mysql+asyncmy://root:test_password@localhost:13306/test_db",
pool_recycle=3600,
pool_size=2,
max_overflow=2,
)
async def asyncTearDown(self):
await self._engine.dispose()
# self._container_id.stop()
super().tearDown()
async def test_1(self):
async with self._engine.connect() as conn:
conn.execute("select 1")
Error
Error
Traceback (most recent call last):
File "/home/danilo/.pyenv/versions/3.9.9/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "/home/danilo/Code/clubbi/orders/src/test/clubbi/data/base_repository.py", line 9, in asyncSetUp
self._engine: AsyncEngine = create_async_engine(
File "/home/danilo/.local/share/virtualenvs/orders-_OYRf4S9/lib/python3.9/site-packages/sqlalchemy/ext/asyncio/engine.py", line 40, in create_async_engine
sync_engine = _create_engine(*arg, **kw)
File "<string>", line 2, in create_engine
File "/home/danilo/.local/share/virtualenvs/orders-_OYRf4S9/lib/python3.9/site-packages/sqlalchemy/util/deprecations.py", line 309, in warned
return fn(*args, **kwargs)
File "/home/danilo/.local/share/virtualenvs/orders-_OYRf4S9/lib/python3.9/site-packages/sqlalchemy/engine/create.py", line 560, in create_engine
dbapi = dialect_cls.dbapi(**dbapi_args)
File "/home/danilo/.local/share/virtualenvs/orders-_OYRf4S9/lib/python3.9/site-packages/sqlalchemy/dialects/mysql/asyncmy.py", line 291, in dbapi
__import__("asyncmy"), __import__("pymysql")
ModuleNotFoundError: No module named 'pymysql'
Versions
- OS: Linux
- Python: 3.9.9
- SQLAlchemy: 1.4.29
- Database: Mysql
- DBAPI: asyncmy
Additional context
No response
Activity
dnp1 commentedon Jan 13, 2022
@long2ice just mentioning you because maybe you are interested
dnp1 commentedon Jan 13, 2022
I actually remove the usage of pymysql from asyncmy dialect, and it seems working finally, there's any reason for this coupling?
zzzeek commentedon Jan 14, 2022
this was contributed by @long2ice and the part that is calling on pymysql is at
sqlalchemy/lib/sqlalchemy/dialects/mysql/asyncmy.py
Line 322 in a869dc8
long2ice commentedon Jan 14, 2022
Yes, actually don't need pymysql, I can fix that
sqla-tester commentedon Jan 14, 2022
long2ice has proposed a fix for this issue in the main branch:
Remove pymysql in asyncmy https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/3521
sqla-tester commentedon Jan 14, 2022
long2ice has proposed a fix for this issue in the rel_1_4 branch:
Remove pymysql in asyncmy https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/3522
6 remaining items