Runtime Inspection API — SQLAlchemy 2.0.0b1 documentation
From Get docs
Sqlalchemy/docs/latest/core/inspection
Runtime Inspection API
Available Inspection Targets
Below is a listing of many of the most common inspection targets.
Connectable
(i.e._engine.Engine
,_engine.Connection
) - returns an_reflection.Inspector
object._expression.ClauseElement
- all SQL expression components, including_schema.Table
,_schema.Column
, serve as their own inspection objects, meaning any of these objects passed to_sa.inspect()
return themselves.object
- an object given will be checked by the ORM for a mapping - if so, anInstanceState
is returned representing the mapped state of the object. TheInstanceState
also provides access to per attribute state via theAttributeState
interface as well as the per-flush “history” of any attribute via theHistory
object.type
(i.e. a class) - a class given will be checked by the ORM for a mapping - if so, a_orm.Mapper
for that class is returned.- mapped attribute - passing a mapped attribute to
_sa.inspect()
, such asinspect(MyClass.some_attribute)
, returns aQueryableAttribute
object, which is the descriptor associated with a mapped class. This descriptor refers to aMapperProperty
, which is usually an instance ofColumnProperty
orRelationshipProperty
, via itsQueryableAttribute.property
attribute. AliasedClass
- returns anAliasedInsp
object.