alembic_pg_autogen.inspect

Catalog inspection for PostgreSQL functions, triggers, and views.

Module Contents

Classes

FunctionInfo

A PostgreSQL function or procedure as loaded from the system catalog.

TriggerInfo

A PostgreSQL trigger as loaded from the system catalog.

ViewInfo

A PostgreSQL view as loaded from the system catalog.

Functions

inspect_functions

Bulk-load function definitions from PostgreSQL system catalogs.

inspect_triggers

Bulk-load trigger definitions from PostgreSQL system catalogs.

inspect_views

Bulk-load view definitions from PostgreSQL system catalogs.

_build_schema_filter

Build the SQL WHERE clause fragment and bind params for schema filtering.

Data

API

alembic_pg_autogen.inspect.log = 'getLogger(...)'
class alembic_pg_autogen.inspect.FunctionInfo

Bases: typing.NamedTuple

A PostgreSQL function or procedure as loaded from the system catalog.

schema: str = None
name: str = None
identity_args: str = None
definition: str = None
class alembic_pg_autogen.inspect.TriggerInfo

Bases: typing.NamedTuple

A PostgreSQL trigger as loaded from the system catalog.

schema: str = None
table_name: str = None
trigger_name: str = None
definition: str = None
class alembic_pg_autogen.inspect.ViewInfo

Bases: typing.NamedTuple

A PostgreSQL view as loaded from the system catalog.

Identity is (schema, name); definition is the last field by convention.

schema: str = None
name: str = None
definition: str = None
alembic_pg_autogen.inspect.inspect_functions(conn: sqlalchemy.Connection, schemas: collections.abc.Sequence[str] | None = None) collections.abc.Sequence[alembic_pg_autogen.inspect.FunctionInfo]

Bulk-load function definitions from PostgreSQL system catalogs.

Queries pg_proc joined with pg_namespace to retrieve all user-defined functions and procedures. Uses pg_get_functiondef() for canonical DDL and pg_get_function_identity_arguments() for the overload-distinguishing argument signature.

Args:

conn: An open SQLAlchemy connection. schemas: Optional list of schema names to inspect. When None, all schemas except pg_catalog and

information_schema are included.

Returns:

A sequence of FunctionInfo instances, one per function/procedure.

alembic_pg_autogen.inspect.inspect_triggers(conn: sqlalchemy.Connection, schemas: collections.abc.Sequence[str] | None = None) collections.abc.Sequence[alembic_pg_autogen.inspect.TriggerInfo]

Bulk-load trigger definitions from PostgreSQL system catalogs.

Queries pg_trigger joined with pg_class and pg_namespace to retrieve all user-defined (non-internal) triggers. Uses pg_get_triggerdef() for canonical DDL.

Args:

conn: An open SQLAlchemy connection. schemas: Optional list of schema names to inspect. When None, all schemas except pg_catalog and

information_schema are included.

Returns:

A sequence of TriggerInfo instances, one per trigger.

alembic_pg_autogen.inspect.inspect_views(conn: sqlalchemy.Connection, schemas: collections.abc.Sequence[str] | None = None) collections.abc.Sequence[alembic_pg_autogen.inspect.ViewInfo]

Bulk-load view definitions from PostgreSQL system catalogs.

Queries pg_class joined with pg_namespace to retrieve all user-defined regular views (relkind = 'v'). Reconstructs the full CREATE OR REPLACE VIEW schema.name AS DDL by combining quote_ident() and pg_get_viewdef(oid, true) in the SQL query so that ViewInfo.definition contains complete DDL.

Args:

conn: An open SQLAlchemy connection. schemas: Optional list of schema names to inspect. When None, all schemas except pg_catalog and

information_schema are included.

Returns:

A sequence of ViewInfo instances, one per view.

alembic_pg_autogen.inspect._EXCLUDED_SCHEMAS = ('pg_catalog', 'information_schema')
alembic_pg_autogen.inspect._VIEWS_QUERY = <Multiline-String>
alembic_pg_autogen.inspect._FUNCTIONS_QUERY = <Multiline-String>
alembic_pg_autogen.inspect._TRIGGERS_QUERY = <Multiline-String>
alembic_pg_autogen.inspect._build_schema_filter(schemas: collections.abc.Sequence[str] | None) tuple[str, dict[str, object]]

Build the SQL WHERE clause fragment and bind params for schema filtering.