diff options
author | mike bayer <mike_mp@zzzcomputing.com> | 2021-09-18 14:00:16 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@ci3.zzzcomputing.com> | 2021-09-18 14:00:16 +0000 |
commit | 955e6bd558e15fa1b0cde9a944d6f53d202d91c2 (patch) | |
tree | 61a64b7361ab0890521771a5d185db787482eaaf /lib/sqlalchemy/dialects/mysql | |
parent | c50183274728544e40e7da4fd35cf240da5df656 (diff) | |
parent | 26140c08111da9833dd2eff0b5091494f253db46 (diff) | |
download | sqlalchemy-955e6bd558e15fa1b0cde9a944d6f53d202d91c2.tar.gz |
Merge "Surface driver connection object when using a proxied dialect"
Diffstat (limited to 'lib/sqlalchemy/dialects/mysql')
-rw-r--r-- | lib/sqlalchemy/dialects/mysql/aiomysql.py | 8 | ||||
-rw-r--r-- | lib/sqlalchemy/dialects/mysql/asyncmy.py | 6 | ||||
-rw-r--r-- | lib/sqlalchemy/dialects/mysql/base.py | 4 |
3 files changed, 13 insertions, 5 deletions
diff --git a/lib/sqlalchemy/dialects/mysql/aiomysql.py b/lib/sqlalchemy/dialects/mysql/aiomysql.py index c9a87145e..c5ba635c2 100644 --- a/lib/sqlalchemy/dialects/mysql/aiomysql.py +++ b/lib/sqlalchemy/dialects/mysql/aiomysql.py @@ -13,7 +13,7 @@ r""" .. warning:: The aiomysql dialect as of September, 2021 appears to be unmaintained and no longer functions for Python version 3.10. Please refer to the - :ref:`asyncmy` dialect for current MySQL asyncio functionality. + :ref:`asyncmy` dialect for current MySQL/MariaDD asyncio functionality. The aiomysql dialect is SQLAlchemy's second Python asyncio dialect. @@ -33,6 +33,7 @@ This dialect should normally be used only with the from .pymysql import MySQLDialect_pymysql from ... import pool from ... import util +from ...engine import AdaptedConnection from ...util.concurrency import asyncio from ...util.concurrency import await_fallback from ...util.concurrency import await_only @@ -173,7 +174,7 @@ class AsyncAdapt_aiomysql_ss_cursor(AsyncAdapt_aiomysql_cursor): return self.await_(self._cursor.fetchall()) -class AsyncAdapt_aiomysql_connection: +class AsyncAdapt_aiomysql_connection(AdaptedConnection): await_ = staticmethod(await_only) __slots__ = ("dbapi", "_connection", "_execute_mutex") @@ -306,5 +307,8 @@ class MySQLDialect_aiomysql(MySQLDialect_pymysql): return CLIENT.FOUND_ROWS + def get_driver_connection(self, connection): + return connection._connection + dialect = MySQLDialect_aiomysql diff --git a/lib/sqlalchemy/dialects/mysql/asyncmy.py b/lib/sqlalchemy/dialects/mysql/asyncmy.py index cde43398d..fb96cd686 100644 --- a/lib/sqlalchemy/dialects/mysql/asyncmy.py +++ b/lib/sqlalchemy/dialects/mysql/asyncmy.py @@ -31,6 +31,7 @@ This dialect should normally be used only with the from .pymysql import MySQLDialect_pymysql from ... import pool from ... import util +from ...engine import AdaptedConnection from ...util.concurrency import asynccontextmanager from ...util.concurrency import asyncio from ...util.concurrency import await_fallback @@ -177,7 +178,7 @@ class AsyncAdapt_asyncmy_ss_cursor(AsyncAdapt_asyncmy_cursor): return self.await_(self._cursor.fetchall()) -class AsyncAdapt_asyncmy_connection: +class AsyncAdapt_asyncmy_connection(AdaptedConnection): await_ = staticmethod(await_only) __slots__ = ("dbapi", "_connection", "_execute_mutex", "_ss_cursors") @@ -335,5 +336,8 @@ class MySQLDialect_asyncmy(MySQLDialect_pymysql): return CLIENT.FOUND_ROWS + def get_driver_connection(self, connection): + return connection._connection + dialect = MySQLDialect_asyncmy diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py index 04b0c1b6d..2bba2f81a 100644 --- a/lib/sqlalchemy/dialects/mysql/base.py +++ b/lib/sqlalchemy/dialects/mysql/base.py @@ -2687,8 +2687,8 @@ class MySQLDialect(default.DefaultDialect): # adjust for ConnectionFairy being present # allows attribute set e.g. "connection.autocommit = True" # to work properly - if hasattr(connection, "connection"): - connection = connection.connection + if hasattr(connection, "dbapi_connection"): + connection = connection.dbapi_connection self._set_isolation_level(connection, level) |