class documentation

class ExceptionContextImpl(ExceptionContext):

View In Hierarchy

Implement the .ExceptionContext interface.
Method __init__ Undocumented
Instance Variable connection The _engine.Connection in use during the exception.
Instance Variable engine The _engine.Engine in use during the exception.
Instance Variable execution​_context The .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 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 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, sqlalchemy_exception, engine, connection, cursor, statement, parameters, context, is_disconnect, invalidate_pool_on_disconnect):

Undocumented

connection =

The _engine.Connection in use during the exception.

This member is present, except in the case of a failure when first connecting.

See Also

.ExceptionContext.engine

engine =

The _engine.Engine in use during the exception.

This member should always be present, even in the case of a failure when first connecting.

New in version 1.0.0.
execution_context =

The .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 .ExecutionContext could be constructed.

Note that the .ExceptionContext.statement and .ExceptionContext.parameters members may represent a different value than that of the .ExecutionContext, potentially in the case where a _events.ConnectionEvents.before_cursor_execute event or similar modified the statement/parameters to be sent.

May be None.

invalidate_pool_on_disconnect =

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 _events.ConnectionEvents.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.

New in version 1.0.3.
is_disconnect =

Represent whether the exception as occurred represents a "disconnect" condition.

This flag will always be True or False within the scope of the _events.ConnectionEvents.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.

original_exception =

The exception object which was caught.

This member is always present.

parameters =

Parameter collection that was emitted directly to the DBAPI.

May be None.

sqlalchemy_exception =

The 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 =

String SQL statement that was emitted directly to the DBAPI.

May be None.