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 ? Coder avec une
Intelligence Artificielle
Voir le programme détaillé
Classe « Result »

Méthode sqlalchemy.Result.partitions

Signature de la méthode partitions

def partitions(self, size: 'Optional[int]' = None) -> 'Iterator[Sequence[Row[_TP]]]' 

Description

help(Result.partitions)

Iterate through sub-lists of rows of the size given.

Each list will be of the size given, excluding the last list to
be yielded, which may have a small number of rows.  No empty
lists will be yielded.

The result object is automatically closed when the iterator
is fully consumed.

Note that the backend driver will usually buffer the entire result
ahead of time unless the
:paramref:`.Connection.execution_options.stream_results` execution
option is used indicating that the driver should not pre-buffer
results, if possible.   Not all drivers support this option and
the option is silently ignored for those who do not.

When using the ORM, the :meth:`_engine.Result.partitions` method
is typically more effective from a memory perspective when it is
combined with use of the
:ref:`yield_per execution option <orm_queryguide_yield_per>`,
which instructs both the DBAPI driver to use server side cursors,
if available, as well as instructs the ORM loading internals to only
build a certain amount of ORM objects from a result at a time before
yielding them out.

.. versionadded:: 1.4

:param size: indicate the maximum number of rows to be present
 in each list yielded.  If None, makes use of the value set by
 the :meth:`_engine.Result.yield_per`, method, if it were called,
 or the :paramref:`_engine.Connection.execution_options.yield_per`
 execution option, which is equivalent in this regard.  If
 yield_per weren't set, it makes use of the
 :meth:`_engine.Result.fetchmany` default, which may be backend
 specific and not well defined.

:return: iterator of lists

.. seealso::

    :ref:`engine_stream_results`

    :ref:`orm_queryguide_yield_per` - in the :ref:`queryguide_toplevel`



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