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 ? Sensibilisation à
l'Intelligence Artificielle
Voir le programme détaillé
Classe « Result »

Méthode sqlalchemy.Result.first

Signature de la méthode first

def first(self) -> 'Optional[Row[_TP]]' 

Description

help(Result.first)

Fetch the first row or ``None`` if no row is present.

Closes the result set and discards remaining rows.

.. note::  This method returns one **row**, e.g. tuple, by default.
   To return exactly one single scalar value, that is, the first
   column of the first row, use the
   :meth:`_engine.Result.scalar` method,
   or combine :meth:`_engine.Result.scalars` and
   :meth:`_engine.Result.first`.

   Additionally, in contrast to the behavior of the legacy  ORM
   :meth:`_orm.Query.first` method, **no limit is applied** to the
   SQL query which was invoked to produce this
   :class:`_engine.Result`;
   for a DBAPI driver that buffers results in memory before yielding
   rows, all rows will be sent to the Python process and all but
   the first row will be discarded.

   .. seealso::

        :ref:`migration_20_unify_select`

:return: a :class:`_engine.Row` object, or None
 if no rows remain.

.. seealso::

    :meth:`_engine.Result.scalar`

    :meth:`_engine.Result.one`



Vous êtes un professionnel et vous avez besoin d'une formation ? Programmation Python
Les fondamentaux
Voir le programme détaillé