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é
Classe « Query »

Méthode sqlalchemy.orm.Query.update

Signature de la méthode update

def update(self, values: 'Dict[_DMLColumnArgument, Any]', synchronize_session: 'SynchronizeSessionArgument' = 'auto', update_args: 'Optional[Dict[Any, Any]]' = None) -> 'int' 

Description

help(Query.update)

Perform an UPDATE with an arbitrary WHERE clause.

Updates rows matched by this query in the database.

E.g.::

    sess.query(User).filter(User.age == 25).update(
        {User.age: User.age - 10}, synchronize_session=False
    )

    sess.query(User).filter(User.age == 25).update(
        {"age": User.age - 10}, synchronize_session="evaluate"
    )

.. warning::

    See the section :ref:`orm_expression_update_delete` for important
    caveats and warnings, including limitations when using arbitrary
    UPDATE and DELETE with mapper inheritance configurations.

:param values: a dictionary with attributes names, or alternatively
 mapped attributes or SQL expressions, as keys, and literal
 values or sql expressions as values.   If :ref:`parameter-ordered
 mode <tutorial_parameter_ordered_updates>` is desired, the values can
 be passed as a list of 2-tuples; this requires that the
 :paramref:`~sqlalchemy.sql.expression.update.preserve_parameter_order`
 flag is passed to the :paramref:`.Query.update.update_args` dictionary
 as well.

:param synchronize_session: chooses the strategy to update the
 attributes on objects in the session.   See the section
 :ref:`orm_expression_update_delete` for a discussion of these
 strategies.

:param update_args: Optional dictionary, if present will be passed
 to the underlying :func:`_expression.update` construct as the ``**kw``
 for the object.  May be used to pass dialect-specific arguments such
 as ``mysql_limit``, as well as other special arguments such as
 :paramref:`~sqlalchemy.sql.expression.update.preserve_parameter_order`.

:return: the count of rows matched as returned by the database's
 "row count" feature.


.. seealso::

    :ref:`orm_expression_update_delete`



Vous êtes un professionnel et vous avez besoin d'une formation ? Mise en oeuvre d'IHM
avec Qt et PySide6
Voir le programme détaillé