Skip to content

SQLAlchemy - History Object

Overview

When the history object happend: when insert, update

Component

Each tuple member is an iterable sequence:

added - the collection of items added to the attribute (the first tuple element).

unchanged - the collection of items that have not changed on the attribute (the second tuple element).

deleted - the collection of items that have been removed from the attribute (the third tuple element).

Members

added, deleted, empty(), has_changes(), non_added(), non_deleted(), sum(), unchanged

Class signature

class sqlalchemy.orm.History (builtins.tuple)

attribute sqlalchemy.orm.attributes.History.added: Tuple[()] | List[Any] Alias for field number 0

attribute sqlalchemy.orm.attributes.History.deleted: Tuple[()] | List[Any] Alias for field number 2

method sqlalchemy.orm.attributes.History.empty() → bool Return True if this History has no changes and no existing, unchanged state.

method sqlalchemy.orm.attributes.History.has_changes() → bool Return True if this History has changes.

method sqlalchemy.orm.attributes.History.non_added() → Sequence[Any] Return a collection of unchanged + deleted.

method sqlalchemy.orm.attributes.History.non_deleted() → Sequence[Any] Return a collection of added + unchanged.

method sqlalchemy.orm.attributes.History.sum() → Sequence[Any] Return a collection of added + unchanged + deleted.

attribute sqlalchemy.orm.attributes.History.unchanged: Tuple[()] | List[Any] Alias for field number 1

from sqlalchemy import inspect

hist = inspect(myobject).attrs.myattribute.history

Reference