Defines a dependency between two columns. ``ForeignKey`` is specified as an argument to a :class:`Column` object, e.g.:: t = Table("remote_table", metadata, Column("remote_id", ForeignKey("main_table.id")) ) Note that ``ForeignKey`` is only a marker object that defines a dependency between two columns. The actual constraint is in all cases represented by the :class:`ForeignKeyConstraint` object. This object will be generated automatically when a ``ForeignKey`` is associated with a :class:`Column` which in turn is associated with a :class:`Table`. Conversely, when :class:`ForeignKeyConstraint` is applied to a :class:`Table`, ``ForeignKey`` markers are automatically generated to be present on each associated :class:`Column`, which are also associated with the constraint object. Note that you cannot define a "composite" foreign key constraint, that is a constraint between a grouping of multiple parent/child columns, using ``ForeignKey`` objects. To define this grouping, the :class:`ForeignKeyConstraint` object must be used, and applied to the :class:`Table`. The associated ``ForeignKey`` objects are created automatically. The ``ForeignKey`` objects associated with an individual :class:`Column` object are available in the `foreign_keys` collection of that column. Further examples of foreign key configuration are in :ref:`metadata_foreignkeys`.
Public Member Functions
Static Public Attributes
|quote = None|
|tuple||target_fullname = property(_get_colspec)|
Private Member Functions
Static Private Attributes
|string||__visit_name__ = 'foreign_key'|