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 ? Deep Learning avec Python
et Keras et Tensorflow
Voir le programme détaillé
Module « sqlalchemy.orm »

Fonction attribute_keyed_dict - module sqlalchemy.orm

Signature de la fonction attribute_keyed_dict

def attribute_keyed_dict(attr_name: 'str', *, ignore_unpopulated_attribute: 'bool' = False) -> 'Type[KeyFuncDict[Any, Any]]' 

Description

help(sqlalchemy.orm.attribute_keyed_dict)

A dictionary-based collection type with attribute-based keying.

.. versionchanged:: 2.0 Renamed :data:`.attribute_mapped_collection` to
   :func:`.attribute_keyed_dict`.

Returns a :class:`.KeyFuncDict` factory which will produce new
dictionary keys based on the value of a particular named attribute on
ORM mapped instances to be added to the dictionary.

.. note:: the value of the target attribute must be assigned with its
   value at the time that the object is being added to the
   dictionary collection.   Additionally, changes to the key attribute
   are **not tracked**, which means the key in the dictionary is not
   automatically synchronized with the key value on the target object
   itself.  See :ref:`key_collections_mutations` for further details.

.. seealso::

    :ref:`orm_dictionary_collection` - background on use

:param attr_name: string name of an ORM-mapped attribute
 on the mapped class, the value of which on a particular instance
 is to be used as the key for a new dictionary entry for that instance.
:param ignore_unpopulated_attribute:  if True, and the target attribute
 on an object is not populated at all, the operation will be silently
 skipped.  By default, an error is raised.

 .. versionadded:: 2.0 an error is raised by default if the attribute
    being used for the dictionary key is determined that it was never
    populated with any value.  The
    :paramref:`_orm.attribute_keyed_dict.ignore_unpopulated_attribute`
    parameter may be set which will instead indicate that this condition
    should be ignored, and the append operation silently skipped.
    This is in contrast to the behavior of the 1.x series which would
    erroneously populate the value in the dictionary with an arbitrary key
    value of ``None``.




Vous êtes un professionnel et vous avez besoin d'une formation ? Sensibilisation à
l'Intelligence Artificielle
Voir le programme détaillé