Vous êtes un professionnel et vous avez besoin d'une formation ?
Programmation Python
Les fondamentaux
Voir le programme détaillé
Module « sqlalchemy »
Classe « PrimaryKeyConstraint »
Informations générales
Héritage
builtins.object
Visitable
builtins.object
EventTarget
SchemaEventTarget
SchemaItem
builtins.object
HasConditionalDDL
builtins.object
DialectKWArgs
Constraint
builtins.object
ColumnCollectionMixin
ColumnCollectionConstraint
PrimaryKeyConstraint
Définition
class PrimaryKeyConstraint(ColumnCollectionConstraint):
help(PrimaryKeyConstraint)
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.
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),
)
Constructeur(s)
Liste des attributs statiques
c | <sqlalchemy.util.langhelpers._memoized_property object at 0x0000020DA09BA7B0> |
columns | <sqlalchemy.util.langhelpers._memoized_property object at 0x0000020DA09BA750> |
create_drop_stringify_dialect | default |
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
columns_autoinc_first | |
kwargs | A synonym for :attr:`.DialectKWArgs.dialect_kwargs`. [extrait de kwargs.__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
Méthodes héritées de la classe ColumnCollectionConstraint
__iter__, __len__, __subclasshook__, contains_column, copy
Méthodes héritées de la classe SchemaItem
__repr__
Méthodes héritées de la classe Visitable
__class_getitem__, __init_subclass__
Méthodes héritées de la classe HasConditionalDDL
ddl_if
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 ?
Sensibilisation àl'Intelligence Artificielle
Voir le programme détaillé
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 :