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/engine/interfaces.py | |
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/engine/interfaces.py')
-rw-r--r-- | lib/sqlalchemy/engine/interfaces.py | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/lib/sqlalchemy/engine/interfaces.py b/lib/sqlalchemy/engine/interfaces.py index 8379c731a..d1484718e 100644 --- a/lib/sqlalchemy/engine/interfaces.py +++ b/lib/sqlalchemy/engine/interfaces.py @@ -1056,7 +1056,21 @@ class Dialect(object): .. versionadded:: 1.0.3 """ - pass + + def get_driver_connection(self, connection): + """Returns the connection object as returned by the external driver + package. + + For normal dialects that use a DBAPI compliant driver this call + will just return the ``connection`` passed as argument. + For dialects that instead adapt a non DBAPI compliant driver, like + when adapting an asyncio driver, this call will return the + connection-like object as returned by the driver. + + .. versionadded:: 1.4.24 + + """ + raise NotImplementedError() class CreateEnginePlugin(object): @@ -1719,3 +1733,24 @@ class ExceptionContext(object): .. versionadded:: 1.0.3 """ + + +class AdaptedConnection(object): + """Interface of an adapted connection object to support the DBAPI protocol. + + Used by asyncio dialects to provide a sync-style pep-249 facade on top + of the asyncio connection/cursor API provided by the driver. + + .. versionadded:: 1.4.24 + + """ + + __slots__ = ("_connection",) + + @property + def driver_connection(self): + """The connection object as returned by the driver after a connect.""" + return self._connection + + def __repr__(self): + return "<AdaptedConnection %s>" % self._connection |