]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
re-add aiomysql to the ci, remove unmaintained note
authorFederico Caselli <cfederico87@gmail.com>
Sat, 5 Aug 2023 10:02:53 +0000 (12:02 +0200)
committerFederico Caselli <cfederico87@gmail.com>
Thu, 10 Aug 2023 19:51:55 +0000 (19:51 +0000)
References: #6893
Change-Id: Ifb70975f686eef2b7239ca266e9dbfff1f1007cb

doc/build/changelog/unreleased_14/aiomysql.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/mysql/aiomysql.py
lib/sqlalchemy/dialects/mysql/asyncmy.py
setup.cfg
tox.ini

diff --git a/doc/build/changelog/unreleased_14/aiomysql.rst b/doc/build/changelog/unreleased_14/aiomysql.rst
new file mode 100644 (file)
index 0000000..ef6fc4c
--- /dev/null
@@ -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.
index d4540785c123b99e0ffd76f650374278e8cc0014..97be62523023324051ce3263f559d7d2adafe401 100644 (file)
@@ -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"
index f454dc38fa67bf43957b2dacf2080c3abe441961..7ef942cd91a4409d4d9f20c576316a5447c89756 100644 (file)
@@ -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 <asyncio_toplevel>`
 extension package.
index ed5a4a92e5ab667318ac2e3c8ef7014d51dcdc8a..d45fb5f6c9410fb586473c8aba80bc0c4b5803ca 100644 (file)
--- 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 22dde3f74d48a80a42d6b845908a18478115ac54..390e798d960eab50a73fc2ccc76883f489518678 100644 (file)
--- 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}