Module « sqlalchemy.orm »
Classe « Mapped »
Informations générales
Héritage
builtins.object
Generic
builtins.object
HasMemoized
builtins.object
HasCacheKey
MemoizedHasCacheKey
builtins.object
Immutable
builtins.object
SQLRole
StructuralRole
builtins.object
AllowsLambdaRole
OnClauseRole
builtins.object
SQLRole
StructuralRole
builtins.object
UsesInspection
builtins.object
AllowsLambdaRole
JoinTargetRole
builtins.object
HasCopyInternals
builtins.object
Operators
ColumnOperators
PropComparator
builtins.object
InspectionAttr
builtins.object
_MappedAttribute
QueryableAttribute
Mapped
Définition
class Mapped(QueryableAttribute, Generic):
Description [extrait de Mapped.__doc__]
Represent an ORM mapped :term:`descriptor` attribute for typing purposes.
This class represents the complete descriptor interface for any class
attribute that will have been :term:`instrumented` by the ORM
:class:`_orm.Mapper` class. When used with typing stubs, it is the final
type that would be used by a type checker such as mypy to provide the full
behavioral contract for the attribute.
.. tip::
The :class:`_orm.Mapped` class represents attributes that are handled
directly by the :class:`_orm.Mapper` class. It does not include other
Python descriptor classes that are provided as extensions, including
:ref:`hybrids_toplevel` and the :ref:`associationproxy_toplevel`.
While these systems still make use of ORM-specific superclasses
and structures, they are not :term:`instrumented` by the
:class:`_orm.Mapper` and instead provide their own functionality
when they are accessed on a class.
When using the :ref:`SQLAlchemy Mypy plugin <mypy_toplevel>`, the
:class:`_orm.Mapped` construct is used in typing annotations to indicate to
the plugin those attributes that are expected to be mapped; the plugin also
applies :class:`_orm.Mapped` as an annotation automatically when it scans
through declarative mappings in :ref:`orm_declarative_table` style. For
more indirect mapping styles such as
:ref:`imperative table <orm_imperative_table_configuration>` it is
typically applied explicitly to class level attributes that expect
to be mapped based on a given :class:`_schema.Table` configuration.
:class:`_orm.Mapped` is defined in the
`sqlalchemy2-stubs <https://pypi.org/project/sqlalchemy2-stubs>`_ project
as a :pep:`484` generic class which may subscribe to any arbitrary Python
type, which represents the Python type handled by the attribute::
class MyMappedClass(Base):
__table_ = Table(
"some_table", Base.metadata,
Column("id", Integer, primary_key=True),
Column("data", String(50)),
Column("created_at", DateTime)
)
id : Mapped[int]
data: Mapped[str]
created_at: Mapped[datetime]
For complete background on how to use :class:`_orm.Mapped` with
pep-484 tools like Mypy, see the link below for background on SQLAlchemy's
Mypy plugin.
.. versionadded:: 1.4
.. seealso::
:ref:`mypy_toplevel` - complete background on Mypy integration
Constructeur(s)
Liste des attributs statiques
allows_lambda | True |
dispatch | <sqlalchemy.event.base.AttributeEventsDispatch object at 0x7f40cb8c40d0> |
expression | <sqlalchemy.util.langhelpers.memoized_property object at 0x7f40cbad3370> |
extension_type | symbol('NOT_EXTENSION') |
info | <sqlalchemy.util.langhelpers.memoized_property object at 0x7f40cba927d0> |
is_aliased_class | False |
is_attribute | True |
is_bundle | False |
is_clause_element | False |
is_instance | False |
is_mapper | False |
is_property | False |
is_selectable | False |
parent | <sqlalchemy.util.langhelpers.memoized_property object at 0x7f40cbad29e0> |
property | <sqlalchemy.util.langhelpers.memoized_property object at 0x7f40cbad3460> |
timetuple | None |
uses_inspection | True |
Attributs statiques hérités de la classe PropComparator
prop
Liste des propriétés
adapter | Produce a callable that adapts column expressions [extrait de __doc__] |
Propriétés héritées de la classe PropComparator
info
Liste des opérateurs
Opérateurs hérités de la classe ColumnOperators
__add__, __contains__, __eq__, __ge__, __getitem__, __gt__, __le__, __lshift__, __lt__, __mod__, __mul__, __ne__, __neg__, __radd__, __rmod__, __rmul__, __rshift__, __rsub__, __rtruediv__, __sub__, __truediv__
Liste des opérateurs
Opérateurs hérités de la classe Operators
__and__, __invert__, __or__
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 Generic
__class_getitem__, __init_subclass__, __subclasshook__
Méthodes héritées de la classe QueryableAttribute
__clause_element__, __getattr__, __reduce__, __str__, adapt_to_entity, and_, get_history, hasparent, label, of_type, operate, reverse_operate
Méthodes héritées de la classe HasMemoized
memoized_attribute, memoized_instancemethod
Méthodes héritées de la classe Immutable
params, unique_params
Méthodes héritées de la classe PropComparator
any, any_op, has, has_op, of_type_op
Méthodes héritées de la classe ColumnOperators
__div__, __rdiv__, all_, any_, asc, between, collate, concat, contains, desc, distinct, endswith, ilike, in_, is_, is_distinct_from, is_not, is_not_distinct_from, isnot, isnot_distinct_from, like, match, not_ilike, not_in, not_like, notilike, notin_, notlike, nulls_first, nulls_last, nullsfirst, nullslast, regexp_match, regexp_replace, startswith
Méthodes héritées de la classe Operators
bool_op, op
Méthodes héritées de la classe object
__delattr__,
__dir__,
__format__,
__getattribute__,
__hash__,
__reduce_ex__,
__repr__,
__setattr__,
__sizeof__
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 :