Provides the hierarchy of DDL-defining schema items as well as routines to invoke them for a create/drop call.
Class |
|
Represent an ALTER TABLE ADD CONSTRAINT statement. |
Class |
|
The root of DDL constructs, including those that are sub-elements within the "create table" and other processes. |
Class |
|
Represent a :class:`_schema.Column` as rendered in a CREATE TABLE statement, via the :class:`.CreateTable` construct. |
Class |
|
Undocumented |
Class |
|
Represent a CREATE INDEX statement. |
Class |
|
Represent a CREATE SCHEMA statement. |
Class |
|
Represent a CREATE SEQUENCE statement. |
Class |
|
Represent a CREATE TABLE statement. |
Class | DDL |
A literal DDL statement. |
Class |
|
Undocumented |
Class |
|
Undocumented |
Class |
|
Represent a COMMENT ON COLUMN IS NULL statement. |
Class |
|
Represent an ALTER TABLE DROP CONSTRAINT statement. |
Class |
|
Represent a COMMENT ON CONSTRAINT IS NULL statement. |
Class |
|
Represent a DROP INDEX statement. |
Class |
|
Represent a DROP SCHEMA statement. |
Class |
|
Represent a DROP SEQUENCE statement. |
Class |
|
Represent a DROP TABLE statement. |
Class |
|
Represent a COMMENT ON TABLE '' statement. |
Class |
|
Base class for standalone executable DDL expression constructs. |
Class |
|
No class docstring; 1/1 method documented |
Class |
|
No class docstring; 0/1 instance variable, 1/2 method documented |
Class |
|
No class docstring; 1/1 method documented |
Class |
|
Undocumented |
Class |
|
Undocumented |
Class |
|
Represent a COMMENT ON COLUMN IS statement. |
Class |
|
Represent a COMMENT ON CONSTRAINT IS statement. |
Class |
|
Represent a COMMENT ON TABLE IS statement. |
Function | sort |
Sort a collection of :class:`_schema.Table` objects based on dependency. |
Function | sort |
Sort a collection of :class:`_schema.Table` / :class:`_schema.ForeignKeyConstraint` objects. |
Class | _ |
Undocumented |
Class | _ |
Base class for DDL constructs that represent CREATE and DROP or equivalents. |
Class | _ |
Undocumented |
Class | _ |
Semi-public 'DROP VIEW' construct. |
Iterable[ TableClause]
, skip_fn: Optional[ Callable[ [ ForeignKeyConstraint], bool]]
= None, extra_dependencies: Optional[ typing_Sequence[ Tuple[ TableClause, TableClause]]]
= None) -> List[ Table]
:
(source)
¶
Sort a collection of :class:`_schema.Table` objects based on dependency. This is a dependency-ordered sort which will emit :class:`_schema.Table` objects such that they will follow their dependent :class:`_schema.Table` objects. Tables are dependent on another based on the presence of :class:`_schema.ForeignKeyConstraint` objects as well as explicit dependencies added by :meth:`_schema.Table.add_is_dependent_on`. .. warning:: The :func:`._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 :func:`_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. .. versionchanged:: 1.3.17 - a warning is emitted when :func:`_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. :param tables: a sequence of :class:`_schema.Table` objects. :param skip_fn: optional callable which will be passed a :class:`_schema.ForeignKeyConstraint` object; if it returns True, this constraint will not be considered as a dependency. Note this is **different** from the same parameter in :func:`.sort_tables_and_constraints`, which is instead passed the owning :class:`_schema.ForeignKeyConstraint` object. :param extra_dependencies: a sequence of 2-tuples of tables which will also be considered as dependent on each other. .. seealso:: :func:`.sort_tables_and_constraints` :attr:`_schema.MetaData.sorted_tables` - uses this function to sort
Sort a collection of :class:`_schema.Table` / :class:`_schema.ForeignKeyConstraint` objects. This is a dependency-ordered sort which will emit tuples of ``(Table, [ForeignKeyConstraint, ...])`` such that each :class:`_schema.Table` follows its dependent :class:`_schema.Table` objects. Remaining :class:`_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 :class:`_schema.ForeignKeyConstraint` objects, explicit dependencies added by :meth:`_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. :param tables: a sequence of :class:`_schema.Table` objects. :param filter_fn: optional callable which will be passed a :class:`_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. :param extra_dependencies: a sequence of 2-tuples of tables which will also be considered as dependent on each other. .. versionadded:: 1.0.0 .. seealso:: :func:`.sort_tables`