class documentation

class _ConnectionFairy(object):

View In Hierarchy

Proxies a DBAPI connection and provides return-on-dereference support.

This is an internal object used by the _pool.Pool implementation to provide context management to a DBAPI connection delivered by that _pool.Pool.

The name "fairy" is inspired by the fact that the ._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.

See Also

._ConnectionRecord

Class Method ​_checkout Undocumented
Method __getattr__ Undocumented
Method __init__ Undocumented
Method ​_checkin Undocumented
Method ​_checkout​_existing Undocumented
Method ​_close​_no​_reset Undocumented
Method ​_reset Undocumented
Method close Undocumented
Method connection.setter Undocumented
Method cursor Return a new DBAPI cursor for the underlying connection.
Method detach Separate this connection from its Pool.
Method invalidate Mark this connection as invalidated.
Instance Variable ​_connection​_record A reference to the ._ConnectionRecord object associated with the DBAPI connection.
Instance Variable ​_echo 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 .ConnectionFairy, allowing user-defined data to be associated with the connection.
Property ​_logger Undocumented
Property connection An alias to ._ConnectionFairy.dbapi_connection.
Property driver​_connection The connection object as returned by the driver after a connect.
Property is​_valid Return True if this ._ConnectionFairy still refers to an active DBAPI connection.
Property record​_info Info dictionary associated with the ._ConnectionRecord container referred to by this `.ConnectionFairy.
@classmethod
def _checkout(cls, pool, threadconns=None, fairy=None):

Undocumented

def __getattr__(self, key):

Undocumented

def __init__(self, dbapi_connection, connection_record, echo):

Undocumented

def _checkin(self, reset=True):

Undocumented

def _checkout_existing(self):

Undocumented

def _close_no_reset(self):

Undocumented

def _reset(self, pool):

Undocumented

def close(self):

Undocumented

@connection.setter
def connection(self, value):

Undocumented

def cursor(self, *args, **kwargs):

Return a new DBAPI cursor for the underlying connection.

This method is a proxy for the connection.cursor() DBAPI method.

def detach(self):

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 containing ConnectionRecord is separated from the DB-API connection, and will create a new connection when next used.

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=None, soft=False):

Mark this connection as invalidated.

This method can be called directly, and is also called as a result of the _engine.Connection.invalidate method. When invoked, the DBAPI connection is immediately closed and discarded from further use by the pool. The invalidation mechanism proceeds via the ._ConnectionRecord.invalidate internal method.

Parameters
ean exception object indicating a reason for the invalidation.
soft

if True, the connection isn't closed; instead, this connection will be recycled on next checkout.

New in version 1.0.3.
_connection_record =

A reference to the ._ConnectionRecord object associated with the DBAPI connection.

This is currently an internal accessor which is subject to change.

_echo =

Undocumented

dbapi_connection =

A reference to the actual DBAPI connection being tracked.

New in version 1.4.24.

See Also

._ConnectionFairy.driver_connection

._ConnectionRecord.dbapi_connection

:ref:`faq_dbapi_connection`

Info dictionary associated with the underlying DBAPI connection referred to by this .ConnectionFairy, allowing user-defined data to be associated with the connection.

The data here will follow along with the DBAPI connection including after it is returned to the connection pool and used again in subsequent instances of ._ConnectionFairy. It is shared with the ._ConnectionRecord.info and _engine.Connection.info accessors.

The dictionary associated with a particular DBAPI connection is discarded when the connection itself is discarded.

@property
_logger =

Undocumented

@property
connection =

An alias to ._ConnectionFairy.dbapi_connection.

This alias is deprecated, please use the new name.

Deprecated since version 1.4.24.
@property
driver_connection =

The connection object as returned by the driver after a connect.

New in version 1.4.24.

See Also

._ConnectionFairy.dbapi_connection

._ConnectionRecord.driver_connection

:ref:`faq_dbapi_connection`

@property
is_valid =
Return True if this ._ConnectionFairy still refers to an active DBAPI connection.
@property
record_info =

Info dictionary associated with the ._ConnectionRecord container referred to by this `.ConnectionFairy.

Unlike the ._ConnectionFairy.info dictionary, the lifespan of this dictionary is persistent across connections that are disconnected and/or invalidated within the lifespan of a ._ConnectionRecord.

New in version 1.1.