Logo Search packages:      
Sourcecode: sqlalchemy version File versions  Download package

sqlalchemy::schema::ForeignKey Class Reference

Inheritance diagram for sqlalchemy::schema::ForeignKey:

sqlalchemy::schema::SchemaItem

List of all members.


Detailed Description

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`.

Definition at line 882 of file schema.py.


Public Member Functions

def __init__
def __repr__
def column
def copy
def get_children
def get_referent
def info
def references

Public Attributes

 constraint
 deferrable
 initially
 link_to_name
 name
 ondelete
 onupdate
 parent
 use_alter

Static Public Attributes

 quote = None
tuple target_fullname = property(_get_colspec)

Private Member Functions

def _get_colspec
def _set_parent
def _set_table

Private Attributes

 _colspec

Static Private Attributes

string __visit_name__ = 'foreign_key'

The documentation for this class was generated from the following file:

Generated by  Doxygen 1.6.0   Back to index