Session API — SQLAlchemy 2.0.0b1 documentation
From Get docs
Sqlalchemy/docs/latest/orm/session api
Session API
Session and sessionmaker()
Session Utilities
Attribute and State Management Utilities
These functions are provided by the SQLAlchemy attribute instrumentation API to provide a detailed interface for dealing with instances, attribute values, and history. Some of them are useful when constructing event listener functions, such as those described in ORM Events.
- sqlalchemy.orm.attributes.instance_state()
Return the
InstanceState
for a given mapped object.This function is the internal version of
object_state()
. Theobject_state()
and/or the_sa.inspect()
function is preferred here as they each emit an informative exception if the given object is not mapped.