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.orm »

Fonction defer - module sqlalchemy.orm

Signature de la fonction defer

def defer(key: '_AttrType', *addl_attrs: '_AttrType', raiseload: 'bool' = False) -> '_AbstractLoad' 

Description

help(sqlalchemy.orm.defer)

Indicate that the given column-oriented attribute should be
deferred, e.g. not loaded until accessed.

This function is part of the :class:`_orm.Load` interface and supports
both method-chained and standalone operation.

e.g.::

    from sqlalchemy.orm import defer

    session.query(MyClass).options(
        defer(MyClass.attribute_one), defer(MyClass.attribute_two)
    )

To specify a deferred load of an attribute on a related class,
the path can be specified one token at a time, specifying the loading
style for each link along the chain.  To leave the loading style
for a link unchanged, use :func:`_orm.defaultload`::

    session.query(MyClass).options(
        defaultload(MyClass.someattr).defer(RelatedClass.some_column)
    )

Multiple deferral options related to a relationship can be bundled
at once using :meth:`_orm.Load.options`::


    select(MyClass).options(
        defaultload(MyClass.someattr).options(
            defer(RelatedClass.some_column),
            defer(RelatedClass.some_other_column),
            defer(RelatedClass.another_column),
        )
    )

:param key: Attribute to be deferred.

:param raiseload: raise :class:`.InvalidRequestError` rather than
 lazy loading a value when the deferred attribute is accessed. Used
 to prevent unwanted SQL from being emitted.

.. versionadded:: 1.4

.. seealso::

    :ref:`orm_queryguide_column_deferral` - in the
    :ref:`queryguide_toplevel`

    :func:`_orm.load_only`

    :func:`_orm.undefer`



Vous êtes un professionnel et vous avez besoin d'une formation ? Calcul scientifique
avec Python
Voir le programme détaillé