class documentation

Proxies a DBAPI connection and provides return-on-dereference support. This is an internal object used by the :class:`_pool.Pool` implementation to provide context management to a DBAPI connection delivered by that :class:`_pool.Pool`. The public facing interface for this class is described by the :class:`.PoolProxiedConnection` class. See that class for public API details. The name "fairy" is inspired by the fact that the :class:`._ConnectionFairy` object's lifespan is transitory, as it lasts only for the length of a specific DBAPI connection being checked out from the pool, and additionally that as a transparent proxy, it is mostly invisible. .. seealso:: :class:`.PoolProxiedConnection` :class:`.ConnectionPoolEntry`

Method __getattr__ Undocumented
Method __init__ Undocumented
Method close Release this connection back to the pool.
Method cursor Undocumented
Method detach Separate this connection from its Pool.
Method invalidate Mark the managed connection as invalidated.
Class Variable __slots__ Undocumented
Class Variable pool Undocumented
Instance Variable dbapi_connection A reference to the actual DBAPI connection being tracked.
Instance Variable info Info dictionary associated with the underlying DBAPI connection referred to by this :class:`.ManagesConnection` instance, allowing user-defined data to be associated with the connection.
Property connection Undocumented
Property driver_connection The "driver level" connection object as used by the Python DBAPI or database driver.
Property is_detached Return True if this :class:`.PoolProxiedConnection` is detached from its pool.
Property is_valid Return True if this :class:`.PoolProxiedConnection` still refers to an active DBAPI connection.
Property record_info Persistent info dictionary associated with this :class:`.ManagesConnection`.
Class Method _checkout Undocumented
Method _checkin Undocumented
Method _checkout_existing Undocumented
Method _close Undocumented
Method _close_special Undocumented
Method _reset Undocumented
Instance Variable _connection_record Undocumented
Instance Variable _counter Undocumented
Instance Variable _echo Undocumented
Instance Variable _pool Undocumented
Property _logger Undocumented

Inherited from PoolProxiedConnection:

Method commit Undocumented
Method rollback Undocumented
def __getattr__(self, key: str) -> Any: (source)

Undocumented

def __init__(self, pool: Pool, dbapi_connection: DBAPIConnection, connection_record: _ConnectionRecord, echo: log._EchoFlagType): (source)

Undocumented

def close(self): (source)

Release this connection back to the pool. The :meth:`.PoolProxiedConnection.close` method shadows the :pep:`249` ``.close()`` method, altering its behavior to instead :term:`release` the proxied connection back to the connection pool. Upon release to the pool, whether the connection stays "opened" and pooled in the Python process, versus actually closed out and removed from the Python process, is based on the pool implementation in use and its configuration and current state.

def cursor(self, *args: Any, **kwargs: Any) -> DBAPICursor: (source)
def detach(self): (source)

Separate this connection from its Pool. This means that the connection will no longer be returned to the pool when closed, and will instead be literally closed. The associated :class:`.ConnectionPoolEntry` is de-associated from this DBAPI connection. Note that any overall connection limiting constraints imposed by a Pool implementation may be violated after a detach, as the detached connection is removed from the pool's knowledge and control.

def invalidate(self, e: Optional[BaseException] = None, soft: bool = False): (source)

Mark the managed connection as invalidated. :param e: an exception object indicating a reason for the invalidation. :param soft: if True, the connection isn't closed; instead, this connection will be recycled on next checkout. .. seealso:: :ref:`pool_connection_invalidation`

Undocumented

dbapi_connection = (source)

A reference to the actual DBAPI connection being tracked. This is a :pep:`249`-compliant object that for traditional sync-style dialects is provided by the third-party DBAPI implementation in use. For asyncio dialects, the implementation is typically an adapter object provided by the SQLAlchemy dialect itself; the underlying asyncio object is available via the :attr:`.ManagesConnection.driver_connection` attribute. SQLAlchemy's interface for the DBAPI connection is based on the :class:`.DBAPIConnection` protocol object .. seealso:: :attr:`.ManagesConnection.driver_connection` :ref:`faq_dbapi_connection`

@util.ro_memoized_property
info = (source)

Info dictionary associated with the underlying DBAPI connection referred to by this :class:`.ManagesConnection` instance, allowing user-defined data to be associated with the connection. The data in this dictionary is persistent for the lifespan of the DBAPI connection itself, including across pool checkins and checkouts. When the connection is invalidated and replaced with a new one, this dictionary is cleared. For a :class:`.PoolProxiedConnection` instance that's not associated with a :class:`.ConnectionPoolEntry`, such as if it were detached, the attribute returns a dictionary that is local to that :class:`.ConnectionPoolEntry`. Therefore the :attr:`.ManagesConnection.info` attribute will always provide a Python dictionary. .. seealso:: :attr:`.ManagesConnection.record_info`

@property
@util.deprecated('2.0', 'The _ConnectionFairy.connection attribute is deprecated; please use \'driver_connection\'')
connection: DBAPIConnection = (source)

Undocumented

@property
driver_connection: Optional[Any] = (source)

The "driver level" connection object as used by the Python DBAPI or database driver. For traditional :pep:`249` DBAPI implementations, this object will be the same object as that of :attr:`.ManagesConnection.dbapi_connection`. For an asyncio database driver, this will be the ultimate "connection" object used by that driver, such as the ``asyncpg.Connection`` object which will not have standard pep-249 methods. .. versionadded:: 1.4.24 .. seealso:: :attr:`.ManagesConnection.dbapi_connection` :ref:`faq_dbapi_connection`

Return True if this :class:`.PoolProxiedConnection` is detached from its pool.

Return True if this :class:`.PoolProxiedConnection` still refers to an active DBAPI connection.

@util.ro_non_memoized_property
record_info: Optional[_InfoType] = (source)

Persistent info dictionary associated with this :class:`.ManagesConnection`. Unlike the :attr:`.ManagesConnection.info` dictionary, the lifespan of this dictionary is that of the :class:`.ConnectionPoolEntry` which owns it; therefore this dictionary will persist across reconnects and connection invalidation for a particular entry in the connection pool. For a :class:`.PoolProxiedConnection` instance that's not associated with a :class:`.ConnectionPoolEntry`, such as if it were detached, the attribute returns None. Contrast to the :attr:`.ManagesConnection.info` dictionary which is never None. .. seealso:: :attr:`.ManagesConnection.info`

@classmethod
def _checkout(cls, pool: Pool, threadconns: Optional[threading.local] = None, fairy: Optional[_ConnectionFairy] = None) -> _ConnectionFairy: (source)

Undocumented

def _checkin(self, transaction_was_reset: bool = False): (source)

Undocumented

def _checkout_existing(self) -> _ConnectionFairy: (source)

Undocumented

def _close(self): (source)

Undocumented

def _close_special(self, transaction_reset: bool = False): (source)

Undocumented

def _reset(self, pool: Pool, transaction_was_reset: bool, terminate_only: bool, asyncio_safe: bool): (source)

Undocumented

_connection_record = (source)

Undocumented

_counter: int = (source)

Undocumented

Undocumented

Undocumented