Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

104 lines (67 sloc) 2.452 kB

Constraints

The :mod:`constraint` module defines six classes: :class:`Constraint` derived from :class:`DbSchemaObject`, classes :class:`CheckConstraint`, :class:`PrimaryKey`, :class:`ForeignKey` and :class:`UniqueConstraint` derived from :class:`Constraint`, and :class:`ConstraintDict` derived from :class:`DbObjectDict`.

Constraint

Class :class:`Constraint` is derived from :class:`~pyrseas.dbobject.DbSchemaObject` and represents a constraint on a database table. Its :attr:`keylist` attributes are the schema name, the table name and the constraint name.

Check Constraint

:class:`CheckConstraint` is derived from :class:`Constraint` and represents a CHECK constraint.

Primary Key

:class:`PrimaryKey` is derived from :class:`Constraint` and represents a primary key constraint.

Foreign Key

:class:`ForeignKey` is derived from :class:`Constraint` and represents a foreign key constraint.

The following shows a foreign key segment of a map returned by :meth:`to_map` and expected as argument by :meth:`ConstraintDict.diff_map` exemplifying various possibilities:

{'t1_fgn_key1':
    {
    'columns': ['c2', 'c3'],
    'on_delete': 'restrict',
    'on_update': 'set null',
    'references':
        {'columns': ['pc2', 'pc1'], 'schema': 's1', 'table': 't2'}
    }
}

Unique Constraint

:class:`UniqueConstraint` is derived from :class:`Constraint` and represents a UNIQUE, non-primary key constraint.

Constraint Dictionary

Class :class:`ConstraintDict` is a dictionary derived from :class:`~pyrseas.dbobject.DbObjectDict` and represents the collection of constraints in a database.

Jump to Line
Something went wrong with that request. Please try again.