Skip to content

asyncmy dialect depends on pymysql, however it's not referenced at setup.cfg #7567

Closed
@dnp1

Description

@dnp1

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

dnp1 commented on Jan 13, 2022

@dnp1
Author

@long2ice just mentioning you because maybe you are interested

dnp1

dnp1 commented on Jan 13, 2022

@dnp1
Author

I actually remove the usage of pymysql from asyncmy dialect, and it seems working finally, there's any reason for this coupling?

added
bugSomething isn't working
fairly easymaybe a little more involved than "easy' but still doable for motivated newcomers
PRs (with tests!) welcomea fix or feature which is appropriate to be implemented by volunteers
and removed
requires triageNew issue that requires categorization
on Jan 14, 2022
added this to the 1.4.x milestone on Jan 14, 2022
zzzeek

zzzeek commented on Jan 14, 2022

@zzzeek
Member

this was contributed by @long2ice and the part that is calling on pymysql is at

from pymysql.constants import CLIENT
. there should be no need for this as asyncmy seems to have the constant defined at https://github.com/long2ice/asyncmy/blob/dev/asyncmy/constants/CLIENT.py

long2ice

long2ice commented on Jan 14, 2022

@long2ice
Contributor

Yes, actually don't need pymysql, I can fix that

sqla-tester

sqla-tester commented on Jan 14, 2022

@sqla-tester
Collaborator

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

sqla-tester commented on Jan 14, 2022

@sqla-tester
Collaborator

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

removed
PRs (with tests!) welcomea fix or feature which is appropriate to be implemented by volunteers
on Jan 14, 2022

6 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingfairly easymaybe a little more involved than "easy' but still doable for motivated newcomersmysql

Type

No type

Projects

No projects

Relationships

None yet

    Development

    Participants

    @zzzeek@dnp1@sqla-tester@long2ice@CaselIT

    Issue actions

      asyncmy dialect depends on pymysql, however it's not referenced at setup.cfg · Issue #7567 · sqlalchemy/sqlalchemy