alembic_pg_autogen.inspect¶
Catalog inspection for PostgreSQL functions, triggers, and views.
Module Contents¶
Classes¶
A PostgreSQL function or procedure as loaded from the system catalog. |
|
A PostgreSQL trigger as loaded from the system catalog. |
|
A PostgreSQL view as loaded from the system catalog. |
Functions¶
Bulk-load function definitions from PostgreSQL system catalogs. |
|
Bulk-load trigger definitions from PostgreSQL system catalogs. |
|
Bulk-load view definitions from PostgreSQL system catalogs. |
|
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.NamedTupleA PostgreSQL function or procedure as loaded from the system catalog.
- class alembic_pg_autogen.inspect.TriggerInfo¶
Bases:
typing.NamedTupleA PostgreSQL trigger as loaded from the system catalog.
- class alembic_pg_autogen.inspect.ViewInfo¶
Bases:
typing.NamedTupleA PostgreSQL view as loaded from the system catalog.
Identity is
(schema, name);definitionis the last field by convention.
- 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_procjoined withpg_namespaceto retrieve all user-defined functions and procedures. Usespg_get_functiondef()for canonical DDL andpg_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_catalogandinformation_schemaare included.- Returns:
A sequence of
FunctionInfoinstances, 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_triggerjoined withpg_classandpg_namespaceto retrieve all user-defined (non-internal) triggers. Usespg_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_catalogandinformation_schemaare included.- Returns:
A sequence of
TriggerInfoinstances, 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_classjoined withpg_namespaceto retrieve all user-defined regular views (relkind = 'v'). Reconstructs the fullCREATE OR REPLACE VIEW schema.name ASDDL by combiningquote_ident()andpg_get_viewdef(oid, true)in the SQL query so thatViewInfo.definitioncontains complete DDL.- Args:
conn: An open SQLAlchemy connection. schemas: Optional list of schema names to inspect. When None, all schemas except
pg_catalogandinformation_schemaare included.- Returns:
A sequence of
ViewInfoinstances, 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>¶