class documentation

class ExceptionContextImpl(ExceptionContext): (source)

View In Hierarchy

Implement the :class:`.ExceptionContext` interface.

Method __init__ Undocumented
Class Variable __slots__ Undocumented
Instance Variable connection The :class:`_engine.Connection` in use during the exception.
Instance Variable dialect The :class:`_engine.Dialect` in use.
Instance Variable engine The :class:`_engine.Engine` in use during the exception.
Instance Variable execution_context The :class:`.ExecutionContext` corresponding to the execution operation in progress.
Instance Variable invalidate_pool_on_disconnect Represent whether all connections in the pool should be invalidated when a "disconnect" condition is in effect.
Instance Variable is_disconnect Represent whether the exception as occurred represents a "disconnect" condition.
Instance Variable is_pre_ping Indicates if this error is occurring within the "pre-ping" step performed when :paramref:`_sa.create_engine.pool_pre_ping` is set to ``True``. In this mode, the :attr:`.ExceptionContext.engine` attribute will be ``None``...
Instance Variable original_exception The exception object which was caught.
Instance Variable parameters Parameter collection that was emitted directly to the DBAPI.
Instance Variable sqlalchemy_exception The :class:`sqlalchemy.exc.StatementError` which wraps the original, and will be raised if exception handling is not circumvented by the event.
Instance Variable statement String SQL statement that was emitted directly to the DBAPI.

Inherited from ExceptionContext:

Class Variable chained_exception The exception that was returned by the previous handler in the exception chain, if any.
Class Variable cursor The DBAPI cursor object.
def __init__(self, exception: BaseException, sqlalchemy_exception: Optional[exc.StatementError], engine: Optional[Engine], dialect: Dialect, connection: Optional[Connection], cursor: Optional[DBAPICursor], statement: Optional[str], parameters: Optional[_DBAPIAnyExecuteParams], context: Optional[ExecutionContext], is_disconnect: bool, invalidate_pool_on_disconnect: bool, is_pre_ping: bool): (source)

Undocumented

connection = (source)

The :class:`_engine.Connection` in use during the exception. This member is present, except in the case of a failure when first connecting. .. seealso:: :attr:`.ExceptionContext.engine`

The :class:`_engine.Dialect` in use. This member is present for all invocations of the event hook. .. versionadded:: 2.0

The :class:`_engine.Engine` in use during the exception. This member is present in all cases except for when handling an error within the connection pool "pre-ping" process.

execution_context = (source)

The :class:`.ExecutionContext` corresponding to the execution operation in progress. This is present for statement execution operations, but not for operations such as transaction begin/end. It also is not present when the exception was raised before the :class:`.ExecutionContext` could be constructed. Note that the :attr:`.ExceptionContext.statement` and :attr:`.ExceptionContext.parameters` members may represent a different value than that of the :class:`.ExecutionContext`, potentially in the case where a :meth:`_events.ConnectionEvents.before_cursor_execute` event or similar modified the statement/parameters to be sent. May be None.

invalidate_pool_on_disconnect = (source)

Represent whether all connections in the pool should be invalidated when a "disconnect" condition is in effect. Setting this flag to False within the scope of the :meth:`_events.DialectEvents.handle_error` event will have the effect such that the full collection of connections in the pool will not be invalidated during a disconnect; only the current connection that is the subject of the error will actually be invalidated. The purpose of this flag is for custom disconnect-handling schemes where the invalidation of other connections in the pool is to be performed based on other conditions, or even on a per-connection basis. .. versionadded:: 1.0.3

is_disconnect = (source)

Represent whether the exception as occurred represents a "disconnect" condition. This flag will always be True or False within the scope of the :meth:`_events.DialectEvents.handle_error` handler. SQLAlchemy will defer to this flag in order to determine whether or not the connection should be invalidated subsequently. That is, by assigning to this flag, a "disconnect" event which then results in a connection and pool invalidation can be invoked or prevented by changing this flag. .. note:: The pool "pre_ping" handler enabled using the :paramref:`_sa.create_engine.pool_pre_ping` parameter does **not** consult this event before deciding if the "ping" returned false, as opposed to receiving an unhandled error. For this use case, the :ref:`legacy recipe based on engine_connect() may be used <pool_disconnects_pessimistic_custom>`. A future API allow more comprehensive customization of the "disconnect" detection mechanism across all functions.

is_pre_ping = (source)

Indicates if this error is occurring within the "pre-ping" step performed when :paramref:`_sa.create_engine.pool_pre_ping` is set to ``True``. In this mode, the :attr:`.ExceptionContext.engine` attribute will be ``None``. The dialect in use is accessible via the :attr:`.ExceptionContext.dialect` attribute. .. versionadded:: 2.0.5

original_exception = (source)

The exception object which was caught. This member is always present.

parameters = (source)

Parameter collection that was emitted directly to the DBAPI. May be None.

sqlalchemy_exception = (source)

The :class:`sqlalchemy.exc.StatementError` which wraps the original, and will be raised if exception handling is not circumvented by the event. May be None, as not all exception types are wrapped by SQLAlchemy. For DBAPI-level exceptions that subclass the dbapi's Error class, this field will always be present.

statement = (source)

String SQL statement that was emitted directly to the DBAPI. May be None.