Runtime Inspection API

    The inspect() function is the entry point to SQLAlchemy’s public API for viewing the configuration and construction of in-memory objects. Depending on the type of object passed to , the return value will either be a related object which provides a known interface, or in many cases it will return the object itself.

    The rationale for inspect() is twofold. One is that it replaces the need to be aware of a large variety of “information getting” functions in SQLAlchemy, such as (deprecated in 1.4), instance_state(), , and others. The other is that the return value of inspect() is guaranteed to obey a documented API, thus allowing third party tools which build on top of SQLAlchemy configurations to be constructed in a forwards-compatible way.

    function sqlalchemy.inspect(subject: Any, raiseerr: bool = True) → Any

    Produce an inspection object for the given target.

    • Parameters:

      • raiseerr – When , if the given subject does not correspond to a known SQLAlchemy inspected type, is raised. If False, is returned.

    Below is a listing of many of the most common inspection targets.