class documentation

Abstract base class for connection pools.

Method __init__ Construct a Pool.
Method connect Return a DBAPI connection from the pool.
Method dispose Dispose of this pool.
Method recreate Return a new :class:`_pool.Pool`, of the same class as this one and configured with identical creation arguments.
Method status Undocumented
Class Variable dispatch Undocumented
Instance Variable echo Undocumented
Instance Variable logging_name Undocumented
Method _close_connection Undocumented
Method _create_connection Called by subclasses to create a new ConnectionRecord.
Method _creator.deleter Undocumented
Method _creator.setter Undocumented
Method _do_get Implementation for :meth:`get`, supplied by subclasses.
Method _do_return_conn Implementation for :meth:`return_conn`, supplied by subclasses.
Method _invalidate Mark all connections established within the generation of the given connection as invalidated.
Method _return_conn Given a _ConnectionRecord, return it to the :class:`_pool.Pool`.
Method _should_wrap_creator Detect if creator accepts a single argument, or is sent as a legacy style no-arg function.
Instance Variable _creator_arg Undocumented
Instance Variable _dialect Undocumented
Instance Variable _invalidate_time Undocumented
Instance Variable _invoke_creator Undocumented
Instance Variable _orig_logging_name Undocumented
Instance Variable _pre_ping Undocumented
Instance Variable _recycle Undocumented
Instance Variable _reset_on_return Undocumented
Property _creator Undocumented
Property _is_asyncio Undocumented

Inherited from Identified:

Class Variable __slots__ Undocumented
Class Variable logger Undocumented
Method _should_log_debug Undocumented
Method _should_log_info Undocumented
Class Variable _echo Undocumented
def __init__(self, creator: Union[_CreatorFnType, _CreatorWRecFnType], recycle: int = -1, echo: log._EchoFlagType = None, logging_name: Optional[str] = None, reset_on_return: _ResetStyleArgType = True, events: Optional[List[Tuple[_ListenerFnType, str]]] = None, dialect: Optional[Union[_ConnDialect, Dialect]] = None, pre_ping: bool = False, _dispatch: Optional[_DispatchCommon[Pool]] = None): (source)

Construct a Pool. :param creator: a callable function that returns a DB-API connection object. The function will be called with parameters. :param recycle: If set to a value other than -1, number of seconds between connection recycling, which means upon checkout, if this timeout is surpassed the connection will be closed and replaced with a newly opened connection. Defaults to -1. :param logging_name: String identifier which will be used within the "name" field of logging records generated within the "sqlalchemy.pool" logger. Defaults to a hexstring of the object's id. :param echo: if True, the connection pool will log informational output such as when connections are invalidated as well as when connections are recycled to the default log handler, which defaults to ``sys.stdout`` for output.. If set to the string ``"debug"``, the logging will include pool checkouts and checkins. The :paramref:`_pool.Pool.echo` parameter can also be set from the :func:`_sa.create_engine` call by using the :paramref:`_sa.create_engine.echo_pool` parameter. .. seealso:: :ref:`dbengine_logging` - further detail on how to configure logging. :param reset_on_return: Determine steps to take on connections as they are returned to the pool, which were not otherwise handled by a :class:`_engine.Connection`. Available from :func:`_sa.create_engine` via the :paramref:`_sa.create_engine.pool_reset_on_return` parameter. :paramref:`_pool.Pool.reset_on_return` can have any of these values: * ``"rollback"`` - call rollback() on the connection, to release locks and transaction resources. This is the default value. The vast majority of use cases should leave this value set. * ``"commit"`` - call commit() on the connection, to release locks and transaction resources. A commit here may be desirable for databases that cache query plans if a commit is emitted, such as Microsoft SQL Server. However, this value is more dangerous than 'rollback' because any data changes present on the transaction are committed unconditionally. * ``None`` - don't do anything on the connection. This setting may be appropriate if the database / DBAPI works in pure "autocommit" mode at all times, or if a custom reset handler is established using the :meth:`.PoolEvents.reset` event handler. * ``True`` - same as 'rollback', this is here for backwards compatibility. * ``False`` - same as None, this is here for backwards compatibility. For further customization of reset on return, the :meth:`.PoolEvents.reset` event hook may be used which can perform any connection activity desired on reset. .. seealso:: :ref:`pool_reset_on_return` :meth:`.PoolEvents.reset` :param events: a list of 2-tuples, each of the form ``(callable, target)`` which will be passed to :func:`.event.listen` upon construction. Provided here so that event listeners can be assigned via :func:`_sa.create_engine` before dialect-level listeners are applied. :param dialect: a :class:`.Dialect` that will handle the job of calling rollback(), close(), or commit() on DBAPI connections. If omitted, a built-in "stub" dialect is used. Applications that make use of :func:`_sa.create_engine` should not use this parameter as it is handled by the engine creation strategy. .. versionadded:: 1.1 - ``dialect`` is now a public parameter to the :class:`_pool.Pool`. :param pre_ping: if True, the pool will emit a "ping" (typically "SELECT 1", but is dialect-specific) on the connection upon checkout, to test if the connection is alive or not. If not, the connection is transparently re-connected and upon success, all other pooled connections established prior to that timestamp are invalidated. Requires that a dialect is passed as well to interpret the disconnection error. .. versionadded:: 1.2

Return a DBAPI connection from the pool. The connection is instrumented such that when its ``close()`` method is called, the connection will be returned to the pool.

def dispose(self): (source)

Dispose of this pool. This method leaves the possibility of checked-out connections remaining open, as it only affects connections that are idle in the pool. .. seealso:: :meth:`Pool.recreate`

def recreate(self) -> Pool: (source)

Return a new :class:`_pool.Pool`, of the same class as this one and configured with identical creation arguments. This method is used in conjunction with :meth:`dispose` to close out an entire :class:`_pool.Pool` and create a new one in its place.

dispatch: dispatcher[Pool] = (source)

Undocumented

logging_name = (source)
def _close_connection(self, connection: DBAPIConnection, *, terminate: bool = False): (source)

Undocumented

def _create_connection(self) -> ConnectionPoolEntry: (source)

Called by subclasses to create a new ConnectionRecord.

@_creator.deleter
def _creator(self): (source)

Undocumented

Undocumented

def _invalidate(self, connection: PoolProxiedConnection, exception: Optional[BaseException] = None, _checkin: bool = True): (source)

Mark all connections established within the generation of the given connection as invalidated. If this pool's last invalidate time is before when the given connection was created, update the timestamp til now. Otherwise, no action is performed. Connections with a start time prior to this pool's invalidation time will be recycled upon next checkout.

def _return_conn(self, record: ConnectionPoolEntry): (source)

Given a _ConnectionRecord, return it to the :class:`_pool.Pool`. This method is called when an instrumented DBAPI connection has its ``close()`` method called.

def _should_wrap_creator(self, creator: Union[_CreatorFnType, _CreatorWRecFnType]) -> _CreatorWRecFnType: (source)

Detect if creator accepts a single argument, or is sent as a legacy style no-arg function.

_creator_arg = (source)

Undocumented

_invalidate_time = (source)

Undocumented

_invoke_creator = (source)

Undocumented

_orig_logging_name = (source)

Undocumented

_pre_ping = (source)

Undocumented

_recycle = (source)

Undocumented

_reset_on_return = (source)

Undocumented