class documentation

class AssertionPool(Pool): (source)

View In Hierarchy

A :class:`_pool.Pool` that allows at most one checked out connection at any given time. This will raise an exception if more than one connection is checked out at a time. Useful for debugging code that is using more connections than desired.

Method __init__ Construct a 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
Method _do_get Implementation for :meth:`get`, supplied by subclasses.
Method _do_return_conn Implementation for :meth:`return_conn`, supplied by subclasses.
Instance Variable _checked_out Undocumented
Instance Variable _checkout_traceback Undocumented
Instance Variable _conn Undocumented
Instance Variable _store_traceback Undocumented

Inherited from Pool:

Method connect Return a DBAPI connection from the pool.
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 _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 (via Pool):

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, *args: Any, **kw: Any): (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

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) -> AssertionPool: (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.

def status(self) -> str: (source)

Undocumented

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

Implementation for :meth:`get`, supplied by subclasses.

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

Implementation for :meth:`return_conn`, supplied by subclasses.

_checked_out: bool = (source)

Undocumented

_checkout_traceback = (source)

Undocumented

Undocumented

_store_traceback = (source)

Undocumented