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

Méthode sqlalchemy.TableValuedAlias.render_derived

Signature de la méthode render_derived

def render_derived(self, name: 'Optional[str]' = None, with_types: 'bool' = False) -> 'TableValuedAlias' 

Description

help(TableValuedAlias.render_derived)

Apply "render derived" to this :class:`_sql.TableValuedAlias`.

This has the effect of the individual column names listed out
after the alias name in the "AS" sequence, e.g.:

.. sourcecode:: pycon+sql

    >>> print(
    ...     select(
    ...         func.unnest(array(["one", "two", "three"]))
    ...         .table_valued("x", with_ordinality="o")
    ...         .render_derived()
    ...     )
    ... )
    {printsql}SELECT anon_1.x, anon_1.o
    FROM unnest(ARRAY[%(param_1)s, %(param_2)s, %(param_3)s]) WITH ORDINALITY AS anon_1(x, o)

The ``with_types`` keyword will render column types inline within
the alias expression (this syntax currently applies to the
PostgreSQL database):

.. sourcecode:: pycon+sql

    >>> print(
    ...     select(
    ...         func.json_to_recordset('[{"a":1,"b":"foo"},{"a":"2","c":"bar"}]')
    ...         .table_valued(column("a", Integer), column("b", String))
    ...         .render_derived(with_types=True)
    ...     )
    ... )
    {printsql}SELECT anon_1.a, anon_1.b FROM json_to_recordset(:json_to_recordset_1)
    AS anon_1(a INTEGER, b VARCHAR)

:param name: optional string name that will be applied to the alias
 generated.  If left as None, a unique anonymizing name will be used.

:param with_types: if True, the derived columns will include the
 datatype specification with each column. This is a special syntax
 currently known to be required by PostgreSQL for some SQL functions.



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