class ExceptionContext: (source)
Known subclasses: sqlalchemy.engine.base.ExceptionContextImpl
Encapsulate information about an error condition in progress. This object exists solely to be passed to the :meth:`_events.DialectEvents.handle_error` event, supporting an interface that can be extended without backwards-incompatibility.
Class Variable | __slots__ |
Undocumented |
Class Variable | chained |
The exception that was returned by the previous handler in the exception chain, if any. |
Class Variable | connection |
The :class:`_engine.Connection` in use during the exception. |
Class Variable | cursor |
The DBAPI cursor object. |
Class Variable | dialect |
The :class:`_engine.Dialect` in use. |
Class Variable | engine |
The :class:`_engine.Engine` in use during the exception. |
Class Variable | execution |
The :class:`.ExecutionContext` corresponding to the execution operation in progress. |
Class Variable | invalidate |
Represent whether all connections in the pool should be invalidated when a "disconnect" condition is in effect. |
Class Variable | is |
Represent whether the exception as occurred represents a "disconnect" condition. |
Class Variable | is |
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``... |
Class Variable | original |
The exception object which was caught. |
Class Variable | parameters |
Parameter collection that was emitted directly to the DBAPI. |
Class Variable | sqlalchemy |
The :class:`sqlalchemy.exc.StatementError` which wraps the original, and will be raised if exception handling is not circumvented by the event. |
Class Variable | statement |
String SQL statement that was emitted directly to the DBAPI. |
The exception that was returned by the previous handler in the exception chain, if any. If present, this exception will be the one ultimately raised by SQLAlchemy unless a subsequent handler replaces it. May be None.
sqlalchemy.engine.base.ExceptionContextImpl
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`
sqlalchemy.engine.base.ExceptionContextImpl
The :class:`_engine.Dialect` in use. This member is present for all invocations of the event hook. .. versionadded:: 2.0
sqlalchemy.engine.base.ExceptionContextImpl
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.
sqlalchemy.engine.base.ExceptionContextImpl
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.
sqlalchemy.engine.base.ExceptionContextImpl
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
sqlalchemy.engine.base.ExceptionContextImpl
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.
sqlalchemy.engine.base.ExceptionContextImpl
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
sqlalchemy.engine.base.ExceptionContextImpl
The exception object which was caught. This member is always present.
sqlalchemy.engine.base.ExceptionContextImpl
Parameter collection that was emitted directly to the DBAPI. May be None.
sqlalchemy.engine.base.ExceptionContextImpl
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.
sqlalchemy.engine.base.ExceptionContextImpl
String SQL statement that was emitted directly to the DBAPI. May be None.