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_2_0_20~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3db54a4825524755566c6bd3f69b79568203ae99;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git re-add aiomysql to the ci, remove unmaintained note References: #6893 Change-Id: Ifb70975f686eef2b7239ca266e9dbfff1f1007cb --- 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 d4540785c1..97be625230 100644 --- a/lib/sqlalchemy/dialects/mysql/aiomysql.py +++ b/lib/sqlalchemy/dialects/mysql/aiomysql.py @@ -13,13 +13,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 @@ -58,7 +51,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__()) @@ -104,10 +97,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 @@ -157,9 +147,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__()) @@ -225,6 +213,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 ( @@ -267,6 +256,18 @@ class AsyncAdapt_aiomysql_dbapi: await_only(creator_fn(*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 f454dc38fa..7ef942cd91 100644 --- a/lib/sqlalchemy/dialects/mysql/asyncmy.py +++ b/lib/sqlalchemy/dialects/mysql/asyncmy.py @@ -13,10 +13,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 ed5a4a92e5..d45fb5f6c9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -71,7 +71,7 @@ pymysql = pymysql aiomysql = %(asyncio)s - aiomysql + aiomysql>=0.2.0 asyncmy = %(asyncio)s asyncmy>=0.2.3,!=0.2.4,!=0.2.6 diff --git a/tox.ini b/tox.ini index 22dde3f74d..390e798d96 100644 --- a/tox.ini +++ b/tox.ini @@ -25,6 +25,7 @@ extras= mysql: mysql mysql: pymysql mysql: asyncmy + mysql: aiomysql oracle: oracle oracle: oracle_oracledb @@ -126,7 +127,7 @@ setenv= mysql: MYSQL={env:TOX_MYSQL:--db mysql} mysql: EXTRA_MYSQL_DRIVERS={env:EXTRA_MYSQL_DRIVERS:--dbdriver mysqldb --dbdriver pymysql} - py{3,37,38,39,310,311}-mysql: EXTRA_MYSQL_DRIVERS={env:EXTRA_MYSQL_DRIVERS:--dbdriver mysqldb --dbdriver pymysql --dbdriver asyncmy} + py{3,37,38,39,310,311}-mysql: EXTRA_MYSQL_DRIVERS={env:EXTRA_MYSQL_DRIVERS:--dbdriver mysqldb --dbdriver pymysql --dbdriver asyncmy --dbdriver aiomysql} mssql: MSSQL={env:TOX_MSSQL:--db mssql} py{3,37,38,39,310,311}-mssql: EXTRA_MSSQL_DRIVERS={env:EXTRA_MSSQL_DRIVERS:--dbdriver pyodbc --dbdriver pymssql}