Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Vous êtes un professionnel et vous avez besoin d'une formation ? Programmation Python
Les fondamentaux
Voir le programme détaillé
Module « sqlalchemy »

Classe « ForeignKey »

Informations générales

Héritage

    builtins.object
        Visitable
builtins.object
    EventTarget
        SchemaEventTarget
            SchemaItem
        builtins.object
            DialectKWArgs
                ForeignKey

Définition

class ForeignKey(DialectKWArgs, SchemaItem):

help(ForeignKey)

Defines a dependency between two columns.

``ForeignKey`` is specified as an argument to a :class:`_schema.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:`_schema.ForeignKeyConstraint`
object.   This object will be generated automatically when
a ``ForeignKey`` is associated with a :class:`_schema.Column` which
in turn is associated with a :class:`_schema.Table`.   Conversely,
when :class:`_schema.ForeignKeyConstraint` is applied to a
:class:`_schema.Table`,
``ForeignKey`` markers are automatically generated to be
present on each associated :class:`_schema.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:`_schema.ForeignKeyConstraint` object must be used, and applied
to the :class:`_schema.Table`.   The associated ``ForeignKey`` objects
are created automatically.

The ``ForeignKey`` objects associated with an individual
:class:`_schema.Column`
object are available in the `foreign_keys` collection
of that column.

Further examples of foreign key configuration are in
:ref:`metadata_foreignkeys`.

Constructeur(s)

Signature du constructeur Description
__init__(self, column: '_DDLColumnArgument', _constraint: 'Optional[ForeignKeyConstraint]' = None, use_alter: 'bool' = False, name: '_ConstraintNameArgument' = None, onupdate: 'Optional[str]' = None, ondelete: 'Optional[str]' = None, deferrable: 'Optional[bool]' = None, initially: 'Optional[str]' = None, link_to_name: 'bool' = False, match: 'Optional[str]' = None, info: 'Optional[_InfoType]' = None, comment: 'Optional[str]' = None, _unresolvable: 'bool' = False, **dialect_kw: 'Any')

Liste des attributs statiques

Nom de l'attribut Valeur
column<sqlalchemy.util.langhelpers._memoized_property object at 0x0000020DA09BA5D0>
create_drop_stringify_dialectdefault
dialect_kwargs<sqlalchemy.util.langhelpers._memoized_property object at 0x0000020D9F4DE450>
dialect_options<sqlalchemy.util.langhelpers._memoized_property object at 0x0000020D9F4DDD50>
dispatch<sqlalchemy.event.base.DDLEventsDispatch object at 0x0000020D9F843260>
info<sqlalchemy.util.langhelpers._memoized_property object at 0x0000020D9F80A270>

Liste des propriétés

Nom de la propriétéDescription
kwargsA synonym for :attr:`.DialectKWArgs.dialect_kwargs`. [extrait de kwargs.__doc__]
target_fullnameReturn a string based 'column specification' for this [extrait de target_fullname.__doc__]

Liste des opérateurs

Opérateurs hérités de la classe object

__eq__, __ge__, __gt__, __le__, __lt__, __ne__

Liste des méthodes

Toutes les méthodes Méthodes d'instance Méthodes statiques Méthodes dépréciées
Signature de la méthodeDescription
__repr__(self) -> 'str'
copy(self, *, schema: 'Optional[str]' = None, **kw: 'Any') -> 'ForeignKey'
get_referent(self, table: 'FromClause') -> 'Optional[Column[Any]]' Return the :class:`_schema.Column` in the given [extrait de get_referent.__doc__]
references(self, table: 'Table') -> 'bool' Return True if the given :class:`_schema.Table` [extrait de references.__doc__]

Méthodes héritées de la classe SchemaItem

__subclasshook__

Méthodes héritées de la classe Visitable

__class_getitem__, __init_subclass__

Méthodes héritées de la classe DialectKWArgs

argument_for

Méthodes héritées de la classe object

__delattr__, __dir__, __format__, __getattribute__, __getstate__, __hash__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__

Vous êtes un professionnel et vous avez besoin d'une formation ? RAG (Retrieval-Augmented Generation)
et Fine Tuning d'un LLM
Voir le programme détaillé