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 « Select »

Méthode sqlalchemy.Select.with_only_columns

Signature de la méthode with_only_columns

def with_only_columns(self, *entities: '_ColumnsClauseArgument[Any]', maintain_column_froms: 'bool' = False, **_Select__kw: 'Any') -> 'Select[Any]' 

Description

help(Select.with_only_columns)

Return a new :func:`_expression.select` construct with its columns
clause replaced with the given entities.

By default, this method is exactly equivalent to as if the original
:func:`_expression.select` had been called with the given entities.
E.g. a statement::

    s = select(table1.c.a, table1.c.b)
    s = s.with_only_columns(table1.c.b)

should be exactly equivalent to::

    s = select(table1.c.b)

In this mode of operation, :meth:`_sql.Select.with_only_columns`
will also dynamically alter the FROM clause of the
statement if it is not explicitly stated.
To maintain the existing set of FROMs including those implied by the
current columns clause, add the
:paramref:`_sql.Select.with_only_columns.maintain_column_froms`
parameter::

    s = select(table1.c.a, table2.c.b)
    s = s.with_only_columns(table1.c.a, maintain_column_froms=True)

The above parameter performs a transfer of the effective FROMs
in the columns collection to the :meth:`_sql.Select.select_from`
method, as though the following were invoked::

    s = select(table1.c.a, table2.c.b)
    s = s.select_from(table1, table2).with_only_columns(table1.c.a)

The :paramref:`_sql.Select.with_only_columns.maintain_column_froms`
parameter makes use of the :attr:`_sql.Select.columns_clause_froms`
collection and performs an operation equivalent to the following::

    s = select(table1.c.a, table2.c.b)
    s = s.select_from(*s.columns_clause_froms).with_only_columns(table1.c.a)

:param \*entities: column expressions to be used.

:param maintain_column_froms: boolean parameter that will ensure the
 FROM list implied from the current columns clause will be transferred
 to the :meth:`_sql.Select.select_from` method first.

 .. versionadded:: 1.4.23



Vous êtes un professionnel et vous avez besoin d'une formation ? RAG (Retrieval-Augmented Generation)
et Fine Tuning d'un LLM
Voir le programme détaillé