Class | AddConstraint |
Represent an ALTER TABLE ADD CONSTRAINT statement. |
Class | CreateColumn |
Represent a _schema.Column as rendered in a CREATE TABLE statement, via the .CreateTable construct. |
Class | CreateIndex |
Represent a CREATE INDEX statement. |
Class | CreateSchema |
Represent a CREATE SCHEMA statement. |
Class | CreateSequence |
Represent a CREATE SEQUENCE statement. |
Class | CreateTable |
Represent a CREATE TABLE statement. |
Class | DDL |
A literal DDL statement. |
Class | DDLElement |
Base class for DDL expression constructs. |
Class | DropConstraint |
Represent an ALTER TABLE DROP CONSTRAINT statement. |
Class | DropIndex |
Represent a DROP INDEX statement. |
Class | DropSchema |
Represent a DROP SCHEMA statement. |
Class | DropSequence |
Represent a DROP SEQUENCE statement. |
Class | DropTable |
Represent a DROP TABLE statement. |
Class | _CreateDropBase |
Base class for DDL constructs that represent CREATE and DROP or equivalents. |
Class | _DDLCompiles |
No class docstring; 1/1 class variable, 1/2 method documented |
Class | _DropView |
Semi-public 'DROP VIEW' construct. |
Class | DDLBase |
Undocumented |
Class | DropColumnComment |
Represent a COMMENT ON COLUMN IS NULL statement. |
Class | DropTableComment |
Represent a COMMENT ON TABLE '' statement. |
Class | SchemaDropper |
Undocumented |
Class | SchemaGenerator |
Undocumented |
Class | SetColumnComment |
Represent a COMMENT ON COLUMN IS statement. |
Class | SetTableComment |
Represent a COMMENT ON TABLE IS statement. |
Function | sort_tables |
Sort a collection of _schema.Table objects based on dependency. |
Function | sort_tables_and_constraints |
Sort a collection of _schema.Table / _schema.ForeignKeyConstraint objects. |
Sort a collection of _schema.Table
objects based on
dependency.
This is a dependency-ordered sort which will emit _schema.Table
objects such that they will follow their dependent _schema.Table
objects.
Tables are dependent on another based on the presence of
_schema.ForeignKeyConstraint
objects as well as explicit dependencies
added by _schema.Table.add_is_dependent_on
.
Warning
The ._schema.sort_tables
function cannot by itself
accommodate automatic resolution of dependency cycles between
tables, which are usually caused by mutually dependent foreign key
constraints. When these cycles are detected, the foreign keys
of these tables are omitted from consideration in the sort.
A warning is emitted when this condition occurs, which will be an
exception raise in a future release. Tables which are not part
of the cycle will still be returned in dependency order.
To resolve these cycles, the
:paramref:`_schema.ForeignKeyConstraint.use_alter` parameter may be
applied to those constraints which create a cycle. Alternatively,
the _schema.sort_tables_and_constraints
function will
automatically return foreign key constraints in a separate
collection when cycles are detected so that they may be applied
to a schema separately.
_schema.sort_tables
cannot perform a proper sort due to
cyclical dependencies. This will be an exception in a future
release. Additionally, the sort will continue to return
other tables not involved in the cycle in dependency order
which was not the case previously.See Also
.sort_tables_and_constraints
_schema.MetaData.sorted_tables
- uses this function to sort
Parameters | |
tables | a sequence of _schema.Table objects. |
skip_fn | optional callable which will be passed a
_schema.ForeignKey object; if it returns True, this
constraint will not be considered as a dependency. Note this is
different from the same parameter in
.sort_tables_and_constraints , which is
instead passed the owning _schema.ForeignKeyConstraint object. |
extra_dependencies | a sequence of 2-tuples of tables which will also be considered as dependent on each other. |
Sort a collection of _schema.Table
/
_schema.ForeignKeyConstraint
objects.
This is a dependency-ordered sort which will emit tuples of
(Table, [ForeignKeyConstraint, ...]) such that each
_schema.Table
follows its dependent _schema.Table
objects.
Remaining _schema.ForeignKeyConstraint
objects that are separate due to
dependency rules not satisfied by the sort are emitted afterwards
as (None, [ForeignKeyConstraint ...]).
Tables are dependent on another based on the presence of
_schema.ForeignKeyConstraint
objects, explicit dependencies
added by _schema.Table.add_is_dependent_on
,
as well as dependencies
stated here using the :paramref:`~.sort_tables_and_constraints.skip_fn`
and/or :paramref:`~.sort_tables_and_constraints.extra_dependencies`
parameters.
See Also
.sort_tables
Parameters | |
tables | a sequence of _schema.Table objects. |
filter_fn | optional callable which will be passed a
_schema.ForeignKeyConstraint object,
and returns a value based on
whether this constraint should definitely be included or excluded as
an inline constraint, or neither. If it returns False, the constraint
will definitely be included as a dependency that cannot be subject
to ALTER; if True, it will only be included as an ALTER result at
the end. Returning None means the constraint is included in the
table-based result unless it is detected as part of a dependency cycle. |
extra_dependencies | a sequence of 2-tuples of tables which will also be considered as dependent on each other. |
_warn_for_cycles | Undocumented |