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 ? Machine Learning
avec Scikit-Learn
Voir le programme détaillé
Classe « Result »

Méthode sqlalchemy.Result.columns

Signature de la méthode columns

def columns(self, *col_expressions: '_KeyIndexType') -> 'Self' 

Description

help(Result.columns)

Establish the columns that should be returned in each row.

This method may be used to limit the columns returned as well
as to reorder them.   The given list of expressions are normally
a series of integers or string key names.   They may also be
appropriate :class:`.ColumnElement` objects which correspond to
a given statement construct.

.. versionchanged:: 2.0  Due to a bug in 1.4, the
   :meth:`_engine.Result.columns` method had an incorrect behavior
   where calling upon the method with just one index would cause the
   :class:`_engine.Result` object to yield scalar values rather than
   :class:`_engine.Row` objects.   In version 2.0, this behavior
   has been corrected such that calling upon
   :meth:`_engine.Result.columns` with a single index will
   produce a :class:`_engine.Result` object that continues
   to yield :class:`_engine.Row` objects, which include
   only a single column.

E.g.::

    statement = select(table.c.x, table.c.y, table.c.z)
    result = connection.execute(statement)

    for z, y in result.columns("z", "y"):
        ...

Example of using the column objects from the statement itself::

    for z, y in result.columns(
        statement.selected_columns.c.z, statement.selected_columns.c.y
    ):
        ...

.. versionadded:: 1.4

:param \*col_expressions: indicates columns to be returned.  Elements
 may be integer row indexes, string column names, or appropriate
 :class:`.ColumnElement` objects corresponding to a select construct.

:return: this :class:`_engine.Result` object with the modifications
 given.



Vous êtes un professionnel et vous avez besoin d'une formation ? Machine Learning
avec Scikit-Learn
Voir le programme détaillé