SQLAlchemy 1.0 Documentation
Exceptions used with SQLAlchemy.
- exception sqlalchemy.exc.AmbiguousForeignKeysError¶
Raised when more than one foreign key matching can be located between two selectables during a join.
- exception sqlalchemy.exc.ArgumentError¶
Raised when an invalid or conflicting function argument is supplied.
This error generally corresponds to construction time state errors.
- exception sqlalchemy.exc.CircularDependencyError(message, cycles, edges, msg=None)¶
Raised by topological sorts when a circular dependency is detected.
There are two scenarios where this error occurs:
- In a Session flush operation, if two objects are mutually dependent on each other, they can not be inserted or deleted via INSERT or DELETE statements alone; an UPDATE will be needed to post-associate or pre-deassociate one of the foreign key constrained values. The post_update flag described at Rows that point to themselves / Mutually Dependent Rows can resolve this cycle.
- In a MetaData.sorted_tables operation, two ForeignKey or ForeignKeyConstraint objects mutually refer to each other. Apply the use_alter=True flag to one or both, see Creating/Dropping Foreign Key Constraints via ALTER.
- exception sqlalchemy.exc.CompileError¶
Raised when an error occurs during SQL compilation
- exception sqlalchemy.exc.DBAPIError(statement, params, orig, connection_invalidated=False)¶
Raised when the execution of a database operation fails.
Wraps exceptions raised by the DB-API underlying the database operation. Driver-specific implementations of the standard DB-API exception types are wrapped by matching sub-types of SQLAlchemy’s DBAPIError when possible. DB-API’s Error type maps to DBAPIError in SQLAlchemy, otherwise the names are identical. Note that there is no guarantee that different DB-API implementations will raise the same exception type for any given error condition.
DBAPIError features statement and params attributes which supply context regarding the specifics of the statement which had an issue, for the typical case when the error was raised within the context of emitting a SQL statement.
The wrapped exception object is available in the orig attribute. Its type and properties are DB-API implementation specific.
- exception sqlalchemy.exc.DataError(statement, params, orig, connection_invalidated=False)¶
Wraps a DB-API DataError.
- exception sqlalchemy.exc.DatabaseError(statement, params, orig, connection_invalidated=False)¶
Wraps a DB-API DatabaseError.
- exception sqlalchemy.exc.DisconnectionError¶
A disconnect is detected on a raw DB-API connection.
This error is raised and consumed internally by a connection pool. It can be raised by the PoolEvents.checkout() event so that the host pool forces a retry; the exception will be caught three times in a row before the pool gives up and raises InvalidRequestError regarding the connection attempt.
- class sqlalchemy.exc.DontWrapMixin¶
A mixin class which, when applied to a user-defined Exception class, will not be wrapped inside of StatementError if the error is emitted within the process of executing a statement.
from sqlalchemy.exc import DontWrapMixin class MyCustomException(Exception, DontWrapMixin): pass class MySpecialType(TypeDecorator): impl = String def process_bind_param(self, value, dialect): if value == 'invalid': raise MyCustomException("invalid!")
- exception sqlalchemy.exc.IdentifierError¶
Raised when a schema name is beyond the max character limit
- exception sqlalchemy.exc.IntegrityError(statement, params, orig, connection_invalidated=False)¶
Wraps a DB-API IntegrityError.
- exception sqlalchemy.exc.InterfaceError(statement, params, orig, connection_invalidated=False)¶
Wraps a DB-API InterfaceError.
- exception sqlalchemy.exc.InternalError(statement, params, orig, connection_invalidated=False)¶
Wraps a DB-API InternalError.
- exception sqlalchemy.exc.InvalidRequestError¶
SQLAlchemy was asked to do something it can’t do.
This error generally corresponds to runtime state errors.
- exception sqlalchemy.exc.NoForeignKeysError¶
Raised when no foreign keys can be located between two selectables during a join.
- exception sqlalchemy.exc.NoInspectionAvailable¶
A subject passed to sqlalchemy.inspection.inspect() produced no context for inspection.
- exception sqlalchemy.exc.NoReferenceError¶
Raised by ForeignKey to indicate a reference cannot be resolved.
- exception sqlalchemy.exc.NoReferencedColumnError(message, tname, cname)¶
Raised by ForeignKey when the referred Column cannot be located.
- exception sqlalchemy.exc.NoReferencedTableError(message, tname)¶
Raised by ForeignKey when the referred Table cannot be located.
- exception sqlalchemy.exc.NoSuchColumnError¶
A nonexistent column is requested from a RowProxy.
- exception sqlalchemy.exc.NoSuchModuleError¶
Raised when a dynamically-loaded module (usually a database dialect) of a particular name cannot be located.
- exception sqlalchemy.exc.NoSuchTableError¶
Table does not exist or is not visible to a connection.
- exception sqlalchemy.exc.NotSupportedError(statement, params, orig, connection_invalidated=False)¶
Wraps a DB-API NotSupportedError.
- exception sqlalchemy.exc.OperationalError(statement, params, orig, connection_invalidated=False)¶
Wraps a DB-API OperationalError.
- exception sqlalchemy.exc.ProgrammingError(statement, params, orig, connection_invalidated=False)¶
Wraps a DB-API ProgrammingError.
- exception sqlalchemy.exc.ResourceClosedError¶
An operation was requested from a connection, cursor, or other object that’s in a closed state.
- exception sqlalchemy.exc.SADeprecationWarning¶
Issued once per usage of a deprecated API.
- exception sqlalchemy.exc.SAPendingDeprecationWarning¶
Issued once per usage of a deprecated API.
- exception sqlalchemy.exc.SAWarning¶
Issued at runtime.
- exception sqlalchemy.exc.SQLAlchemyError¶
Generic error class.
- exception sqlalchemy.exc.StatementError(message, statement, params, orig)¶
An error occurred during execution of a SQL statement.
The wrapped exception object is available in the orig attribute.
- orig = None¶
The DBAPI exception object.
- params = None¶
The parameter list being used when this exception occurred.
- statement = None¶
The string SQL statement being invoked when this exception occurred.
- exception sqlalchemy.exc.TimeoutError¶
Raised when a connection pool times out on getting a connection.
- exception sqlalchemy.exc.UnboundExecutionError¶
SQL was attempted without a database connection to execute it on.
- exception sqlalchemy.exc.UnsupportedCompilationError(compiler, element_type)¶
Raised when an operation is not supported by the given compiler.
New in version 0.8.3.