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 :

Module « sqlalchemy »

Classe « PrimaryKeyConstraint »

Informations générales

Héritage

builtins.object
    Traversible
builtins.object
    SchemaEventTarget
        SchemaItem
    builtins.object
        DialectKWArgs
            Constraint
        builtins.object
            ColumnCollectionMixin
                ColumnCollectionConstraint
                    PrimaryKeyConstraint

Définition

class PrimaryKeyConstraint(ColumnCollectionConstraint):

Description [extrait de PrimaryKeyConstraint.__doc__]

A table-level PRIMARY KEY constraint.

    The :class:`.PrimaryKeyConstraint` object is present automatically
    on any :class:`_schema.Table` object; it is assigned a set of
    :class:`_schema.Column` objects corresponding to those marked with
    the :paramref:`_schema.Column.primary_key` flag::

        >>> my_table = Table('mytable', metadata,
        ...                 Column('id', Integer, primary_key=True),
        ...                 Column('version_id', Integer, primary_key=True),
        ...                 Column('data', String(50))
        ...     )
        >>> my_table.primary_key
        PrimaryKeyConstraint(
            Column('id', Integer(), table=<mytable>,
                   primary_key=True, nullable=False),
            Column('version_id', Integer(), table=<mytable>,
                   primary_key=True, nullable=False)
        )

    The primary key of a :class:`_schema.Table` can also be specified by using
    a :class:`.PrimaryKeyConstraint` object explicitly; in this mode of usage,
    the "name" of the constraint can also be specified, as well as other
    options which may be recognized by dialects::

        my_table = Table('mytable', metadata,
                    Column('id', Integer),
                    Column('version_id', Integer),
                    Column('data', String(50)),
                    PrimaryKeyConstraint('id', 'version_id',
                                         name='mytable_pk')
                )

    The two styles of column-specification should generally not be mixed.
    An warning is emitted if the columns present in the
    :class:`.PrimaryKeyConstraint`
    don't match the columns that were marked as ``primary_key=True``, if both
    are present; in this case, the columns are taken strictly from the
    :class:`.PrimaryKeyConstraint` declaration, and those columns otherwise
    marked as ``primary_key=True`` are ignored.  This behavior is intended to
    be backwards compatible with previous behavior.

    .. versionchanged:: 0.9.2  Using a mixture of columns within a
       :class:`.PrimaryKeyConstraint` in addition to columns marked as
       ``primary_key=True`` now emits a warning if the lists don't match.
       The ultimate behavior of ignoring those columns marked with the flag
       only is currently maintained for backwards compatibility; this warning
       may raise an exception in a future release.

    For the use case where specific options are to be specified on the
    :class:`.PrimaryKeyConstraint`, but the usual style of using
    ``primary_key=True`` flags is still desirable, an empty
    :class:`.PrimaryKeyConstraint` may be specified, which will take on the
    primary key column collection from the :class:`_schema.Table` based on the
    flags::

        my_table = Table('mytable', metadata,
                    Column('id', Integer, primary_key=True),
                    Column('version_id', Integer, primary_key=True),
                    Column('data', String(50)),
                    PrimaryKeyConstraint(name='mytable_pk',
                                         mssql_clustered=True)
                )

    .. versionadded:: 0.9.2 an empty :class:`.PrimaryKeyConstraint` may now
       be specified for the purposes of establishing keyword arguments with
       the constraint, independently of the specification of "primary key"
       columns within the :class:`_schema.Table` itself; columns marked as
       ``primary_key=True`` will be gathered into the empty constraint's
       column collection.

    

Constructeur(s)

Signature du constructeur Description
__init__(self, *columns, **kw)

Liste des attributs statiques

Nom de l'attribut Valeur
columnsNone
create_drop_stringify_dialectdefault
dialect_kwargs<sqlalchemy.util.langhelpers.memoized_property object at 0x7f40cbecc6d0>
dialect_options<sqlalchemy.util.langhelpers.memoized_property object at 0x7f40cbece8c0>
dispatch<sqlalchemy.event.base.DDLEventsDispatch object at 0x7f40cbc2af40>
info<sqlalchemy.util.langhelpers.memoized_property object at 0x7f40cbc85d20>

Liste des propriétés

Nom de la propriétéDescription
columns_autoinc_first
kwargsA synonym for :attr:`.DialectKWArgs.dialect_kwargs`. [extrait de __doc__]
table

Liste des opérateurs

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

__contains__

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

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

__init_subclass__, __iter__, __len__, __subclasshook__, contains_column, copy

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

__repr__

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

__class_getitem__, get_children

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

argument_for

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

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