From: Federico Caselli Date: Sat, 5 Aug 2023 10:02:53 +0000 (+0200) Subject: re-add aiomysql to the ci, remove unmaintained note X-Git-Tag: rel_1_4_50~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5ba341c4c6f0d7359e48568b7661c7196b67884e;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git re-add aiomysql to the ci, remove unmaintained note References: #6893 Change-Id: Ifb70975f686eef2b7239ca266e9dbfff1f1007cb (cherry picked from commit 8bacaad859b63418c1dd6099b4a8c7f00727c23e) --- diff --git a/doc/build/changelog/unreleased_14/aiomysql.rst b/doc/build/changelog/unreleased_14/aiomysql.rst new file mode 100644 index 0000000000..ef6fc4c94f --- /dev/null +++ b/doc/build/changelog/unreleased_14/aiomysql.rst @@ -0,0 +1,6 @@ +.. change:: + :tags: mysql, usecase + :versions: 2.0.20 + + Updated aiomysql dialect since the dialect appears to be maintained again. + Re-added to the ci testing using version 0.2.0. diff --git a/lib/sqlalchemy/dialects/mysql/aiomysql.py b/lib/sqlalchemy/dialects/mysql/aiomysql.py index 93e500c32b..c5a74b8284 100644 --- a/lib/sqlalchemy/dialects/mysql/aiomysql.py +++ b/lib/sqlalchemy/dialects/mysql/aiomysql.py @@ -11,13 +11,6 @@ r""" :connectstring: mysql+aiomysql://user:password@host:port/dbname[?key=value&key=value...] :url: https://github.com/aio-libs/aiomysql -.. warning:: The aiomysql dialect is not currently tested as part of - SQLAlchemy’s continuous integration. As of September, 2021 the driver - appears to be unmaintained and no longer functions for Python version 3.10, - and additionally depends on a significantly outdated version of PyMySQL. - Please refer to the :ref:`asyncmy` dialect for current MySQL/MariaDB asyncio - functionality. - The aiomysql dialect is SQLAlchemy's second Python asyncio dialect. Using a special asyncio mediation layer, the aiomysql dialect is usable @@ -57,7 +50,7 @@ class AsyncAdapt_aiomysql_cursor: self._connection = adapt_connection._connection self.await_ = adapt_connection.await_ - cursor = self._connection.cursor() + cursor = self._connection.cursor(adapt_connection.dbapi.Cursor) # see https://github.com/aio-libs/aiomysql/issues/543 self._cursor = self.await_(cursor.__aenter__()) @@ -103,10 +96,7 @@ class AsyncAdapt_aiomysql_cursor: async def _execute_async(self, operation, parameters): async with self._adapt_connection._execute_mutex: - if parameters is None: - result = await self._cursor.execute(operation) - else: - result = await self._cursor.execute(operation, parameters) + result = await self._cursor.execute(operation, parameters) if not self.server_side: # aiomysql has a "fake" async result, so we have to pull it out @@ -156,9 +146,7 @@ class AsyncAdapt_aiomysql_ss_cursor(AsyncAdapt_aiomysql_cursor): self._connection = adapt_connection._connection self.await_ = adapt_connection.await_ - cursor = self._connection.cursor( - adapt_connection.dbapi.aiomysql.SSCursor - ) + cursor = self._connection.cursor(adapt_connection.dbapi.SSCursor) self._cursor = self.await_(cursor.__aenter__()) @@ -224,6 +212,7 @@ class AsyncAdapt_aiomysql_dbapi: self.pymysql = pymysql self.paramstyle = "format" self._init_dbapi_attributes() + self.Cursor, self.SSCursor = self._init_cursors_subclasses() def _init_dbapi_attributes(self): for name in ( @@ -265,6 +254,18 @@ class AsyncAdapt_aiomysql_dbapi: await_only(self.aiomysql.connect(*arg, **kw)), ) + def _init_cursors_subclasses(self): + # suppress unconditional warning emitted by aiomysql + class Cursor(self.aiomysql.Cursor): + async def _show_warnings(self, conn): + pass + + class SSCursor(self.aiomysql.SSCursor): + async def _show_warnings(self, conn): + pass + + return Cursor, SSCursor + class MySQLDialect_aiomysql(MySQLDialect_pymysql): driver = "aiomysql" diff --git a/lib/sqlalchemy/dialects/mysql/asyncmy.py b/lib/sqlalchemy/dialects/mysql/asyncmy.py index a27f24bab9..fc0ebe2798 100644 --- a/lib/sqlalchemy/dialects/mysql/asyncmy.py +++ b/lib/sqlalchemy/dialects/mysql/asyncmy.py @@ -11,10 +11,6 @@ r""" :connectstring: mysql+asyncmy://user:password@host:port/dbname[?key=value&key=value...] :url: https://github.com/long2ice/asyncmy -.. note:: The asyncmy dialect as of September, 2021 was added to provide - MySQL/MariaDB asyncio compatibility given that the :ref:`aiomysql` database - driver has become unmaintained, however asyncmy is itself very new. - Using a special asyncio mediation layer, the asyncmy dialect is usable as the backend for the :ref:`SQLAlchemy asyncio ` extension package. diff --git a/setup.cfg b/setup.cfg index b455c8a097..2fa7b765db 100644 --- a/setup.cfg +++ b/setup.cfg @@ -75,7 +75,7 @@ pymysql = pymysql<1;python_version<"3" aiomysql = %(asyncio)s - aiomysql;python_version>="3" + aiomysql>=0.2.0;python_version>="3" asyncmy = %(asyncio)s asyncmy>=0.2.3,!=0.2.4;python_version>="3" diff --git a/tox.ini b/tox.ini index 092104a448..9a198e77d7 100644 --- a/tox.ini +++ b/tox.ini @@ -34,6 +34,7 @@ deps= mysql: .[mysql] mysql: .[pymysql] mysql: .[asyncmy]; python_version >= '3' + mysql: .[aiomysql]; python_version >= '3' # mysql: .[mariadb_connector]; python_version >= '3' oracle: .[oracle] @@ -125,7 +126,7 @@ setenv= mysql: EXTRA_MYSQL_DRIVERS={env:EXTRA_MYSQL_DRIVERS:--dbdriver mysqldb --dbdriver pymysql} # py3{,7,8,9,10,11}-mysql: EXTRA_MYSQL_DRIVERS={env:EXTRA_MYSQL_DRIVERS:--dbdriver mysqldb --dbdriver pymysql --dbdriver mariadbconnector --dbdriver asyncmy} - py3{,7,8,9,10,11}-mysql: EXTRA_MYSQL_DRIVERS={env:EXTRA_MYSQL_DRIVERS:--dbdriver mysqldb --dbdriver pymysql --dbdriver asyncmy} + py3{,7,8,9,10,11}-mysql: EXTRA_MYSQL_DRIVERS={env:EXTRA_MYSQL_DRIVERS:--dbdriver mysqldb --dbdriver pymysql --dbdriver asyncmy --dbdriver aiomysql} mssql: MSSQL={env:TOX_MSSQL:--db mssql}