ORM Exceptions

SQLAlchemy ORM exceptions.

  • sqlalchemy.orm.exc.ConcurrentModificationError
  • alias of sqlalchemy.orm.exc.StaleDataError

  • exception sqlalchemy.orm.exc.DetachedInstanceError(*arg, **kw)

  • An attempt to access unloaded attributes on amapped instance that is detached.

  • exception sqlalchemy.orm.exc.FlushError(*arg, **kw)

  • A invalid condition was detected during flush().

  • exception sqlalchemy.orm.exc.LoaderStrategyException(applied_to_property_type, requesting_property, applies_to, actual_strategy_type, strategy_key)

  • A loader strategy for an attribute does not exist.

  • exception sqlalchemy.orm.exc.MultipleResultsFound(*arg, **kw)

  • A single database result was required but more than one were found.

  • sqlalchemy.orm.exc.NOSTATE = (, )_

  • Exception types that may be raised by instrumentation implementations.
  • exception sqlalchemy.orm.exc.NoResultFound(*arg, **kw)
  • A database result was required but none was found.

  • exception sqlalchemy.orm.exc.ObjectDeletedError(base, state, msg=None)

  • A refresh operation failed to retrieve the databaserow corresponding to an object’s known primary key identity.

A refresh operation proceeds when an expired attribute isaccessed on an object, or when Query.get() isused to retrieve an object which is, upon retrieval, detectedas expired. A SELECT is emitted for the target rowbased on primary key; if no row is returned, thisexception is raised.

The true meaning of this exception is simply thatno row exists for the primary key identifier associatedwith a persistent object. The row may have beendeleted, or in some cases the primary key updatedto a new value, outside of the ORM’s management of the targetobject.

  • exception sqlalchemy.orm.exc.ObjectDereferencedError(*arg, **kw)
  • An operation cannot complete due to an object being garbagecollected.

  • exception sqlalchemy.orm.exc.StaleDataError(*arg, **kw)

  • An operation encountered database state that is unaccounted for.

Conditions which cause this to happen include:

  • A flush may have attempted to update or delete rowsand an unexpected number of rows were matched duringthe UPDATE or DELETE statement. Note that whenversion_id_col is used, rows in UPDATE or DELETE statementsare also matched against the current known versionidentifier.

  • A mapped object with version_id_col was refreshed,and the version number coming back from the database doesnot match that of the object itself.

  • A object is detached from its parent object, howeverthe object was previously attached to a different parentidentity which was garbage collected, and a decisioncannot be made if the new parent was really the mostrecent “parent”.

  • exception sqlalchemy.orm.exc.UnmappedClassError(cls, msg=None)
  • An mapping operation was requested for an unknown class.

  • exception sqlalchemy.orm.exc.UnmappedColumnError(*arg, **kw)

  • Mapping operation was requested on an unknown column.

  • exception sqlalchemy.orm.exc.UnmappedError(*arg, **kw)

  • Base for exceptions that involve expected mappings not present.

  • exception sqlalchemy.orm.exc.UnmappedInstanceError(base, obj, msg=None)

  • An mapping operation was requested for an unknown instance.