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 ? Programmation Python
Les compléments
Voir le programme détaillé
Module « sqlalchemy »

Classe « ColumnElement »

Informations générales

Héritage

        builtins.object
            Visitable
                CompilerElement
        builtins.object
            Visitable
        builtins.object
            HasTraverseInternals
                ExternallyTraversible
        builtins.object
            HasTraverseInternals
                HasCopyInternals
        builtins.object
            HasMemoized
        builtins.object
            HasCacheKey
                MemoizedHasCacheKey
builtins.object
    Visitable
builtins.object
    HasTraverseInternals
        ExternallyTraversible
            SupportsAnnotations
                SupportsWrappingAnnotations
                    ClauseElement
                        DQLDMLClauseElement
                builtins.object
                    TypingOnly
        builtins.object
            SQLRole
        builtins.object
            Generic
                TypedColumnsClauseRole
                    ExpressionElementRole
            builtins.object
                TypingOnly
        builtins.object
            Operators
                ColumnOperators
            builtins.object
                Generic
                    SQLCoreOperations
                        SQLColumnExpression
            builtins.object
                SQLRole
                    StructuralRole
                        DDLExpressionRole
                builtins.object
                    SQLRole
                        DDLConstraintColumnRole
                builtins.object
                    SQLRole
                        DMLColumnRole
                builtins.object
                    SQLRole
                        LimitOffsetRole
            builtins.object
                SQLRole
                    ColumnListRole
                builtins.object
                    UsesInspection
                builtins.object
                    AllowsLambdaRole
                        ColumnsClauseRole
        builtins.object
            SQLRole
                ColumnListRole
                    ByOfRole
                builtins.object
                    AllowsLambdaRole
                        OrderByRole
        builtins.object
            SQLRole
        builtins.object
            Generic
                TypedColumnsClauseRole
                    ExpressionElementRole
                        BinaryElementRole
        builtins.object
            SQLRole
                StructuralRole
            builtins.object
                AllowsLambdaRole
                    OnClauseRole
                        WhereHavingRole
            builtins.object
                SQLRole
                    StructuralRole
                        StatementOptionRole
            builtins.object
                SQLRole
                    ColumnArgumentRole
                        ColumnArgumentOrKeyRole
                            ColumnElement

Définition

class ColumnElement(ColumnArgumentOrKeyRole, StatementOptionRole, WhereHavingRole, BinaryElementRole, OrderByRole, ColumnsClauseRole, LimitOffsetRole, DMLColumnRole, DDLConstraintColumnRole, DDLExpressionRole, SQLColumnExpression, DQLDMLClauseElement):

help(ColumnElement)

Represent a column-oriented SQL expression suitable for usage in the
"columns" clause, WHERE clause etc. of a statement.

While the most familiar kind of :class:`_expression.ColumnElement` is the
:class:`_schema.Column` object, :class:`_expression.ColumnElement`
serves as the basis
for any unit that may be present in a SQL expression, including
the expressions themselves, SQL functions, bound parameters,
literal expressions, keywords such as ``NULL``, etc.
:class:`_expression.ColumnElement`
is the ultimate base class for all such elements.

A wide variety of SQLAlchemy Core functions work at the SQL expression
level, and are intended to accept instances of
:class:`_expression.ColumnElement` as
arguments.  These functions will typically document that they accept a
"SQL expression" as an argument.  What this means in terms of SQLAlchemy
usually refers to an input which is either already in the form of a
:class:`_expression.ColumnElement` object,
or a value which can be **coerced** into
one.  The coercion rules followed by most, but not all, SQLAlchemy Core
functions with regards to SQL expressions are as follows:

    * a literal Python value, such as a string, integer or floating
      point value, boolean, datetime, ``Decimal`` object, or virtually
      any other Python object, will be coerced into a "literal bound
      value".  This generally means that a :func:`.bindparam` will be
      produced featuring the given value embedded into the construct; the
      resulting :class:`.BindParameter` object is an instance of
      :class:`_expression.ColumnElement`.
      The Python value will ultimately be sent
      to the DBAPI at execution time as a parameterized argument to the
      ``execute()`` or ``executemany()`` methods, after SQLAlchemy
      type-specific converters (e.g. those provided by any associated
      :class:`.TypeEngine` objects) are applied to the value.

    * any special object value, typically ORM-level constructs, which
      feature an accessor called ``__clause_element__()``.  The Core
      expression system looks for this method when an object of otherwise
      unknown type is passed to a function that is looking to coerce the
      argument into a :class:`_expression.ColumnElement` and sometimes a
      :class:`_expression.SelectBase` expression.
      It is used within the ORM to
      convert from ORM-specific objects like mapped classes and
      mapped attributes into Core expression objects.

    * The Python ``None`` value is typically interpreted as ``NULL``,
      which in SQLAlchemy Core produces an instance of :func:`.null`.

A :class:`_expression.ColumnElement` provides the ability to generate new
:class:`_expression.ColumnElement`
objects using Python expressions.  This means that Python operators
such as ``==``, ``!=`` and ``<`` are overloaded to mimic SQL operations,
and allow the instantiation of further :class:`_expression.ColumnElement`
instances
which are composed from other, more fundamental
:class:`_expression.ColumnElement`
objects.  For example, two :class:`.ColumnClause` objects can be added
together with the addition operator ``+`` to produce
a :class:`.BinaryExpression`.
Both :class:`.ColumnClause` and :class:`.BinaryExpression` are subclasses
of :class:`_expression.ColumnElement`:

.. sourcecode:: pycon+sql

    >>> from sqlalchemy.sql import column
    >>> column("a") + column("b")
    <sqlalchemy.sql.expression.BinaryExpression object at 0x101029dd0>
    >>> print(column("a") + column("b"))
    {printsql}a + b

.. seealso::

    :class:`_schema.Column`

    :func:`_expression.column`

Constructeur(s)

Signature du constructeur Description
__init__(self, /, *args, **kwargs) Initialize self. See help(type(self)) for accurate signature. [extrait de __init__.__doc__]

Liste des attributs statiques

Nom de l'attribut Valeur
allows_lambdaTrue
base_columns<sqlalchemy.util.langhelpers._memoized_property object at 0x0000020D9F7432A0>
comparator<sqlalchemy.util.langhelpers.HasMemoized.memoized_attribute object at 0x0000020D9F6F0190>
description<sqlalchemy.util.langhelpers._memoized_property object at 0x0000020D9F723AD0>
foreign_keysfrozenset()
inherit_cacheNone
is_clause_elementTrue
is_dmlFalse
is_selectableFalse
keyNone
primary_keyFalse
proxy_set<sqlalchemy.util.langhelpers._memoized_property object at 0x0000020D9F73FF50>
stringify_dialectdefault
supports_executionFalse
timetupleNone
type<sqlalchemy.util.langhelpers._memoized_property object at 0x0000020D9F743230>
uses_inspectionTrue

Liste des propriétés

Nom de la propriétéDescription
anon_key_label
anon_label
entity_namespace
expressionReturn a column expression. [extrait de expression.__doc__]

Liste des opérateurs

Opérateurs hérités de la classe ClauseElement

__invert__

Liste des opérateurs

Opérateurs hérités de la classe ColumnOperators

__add__, __contains__, __eq__, __floordiv__, __ge__, __getitem__, __gt__, __le__, __lshift__, __lt__, __mod__, __mul__, __ne__, __neg__, __radd__, __rfloordiv__, __rmod__, __rmul__, __rshift__, __rsub__, __rtruediv__, __sub__, __truediv__

Liste des opérateurs

Opérateurs hérités de la classe Operators

__and__, __or__

Liste des méthodes

Toutes les méthodes Méthodes d'instance Méthodes statiques Méthodes dépréciées
Signature de la méthodeDescription
__class_getitem__ Parameterizes a generic class. [extrait de __class_getitem__.__doc__]
__getattr__(self, key: 'str') -> 'Any'
__setstate__(self, state)
cast(self, type_: '_TypeEngineArgument[_OPT]') -> 'Cast[_OPT]' Produce a type cast, i.e. ``CAST(<expression> AS <type>)``. [extrait de cast.__doc__]
label(self, name: 'Optional[str]') -> 'Label[_T]' Produce a column label, i.e. ``<columnname> AS <name>``. [extrait de label.__doc__]
operate(self, op: 'operators.OperatorType', *other: 'Any', **kwargs: 'Any') -> 'ColumnElement[Any]'
reverse_operate(self, op: 'operators.OperatorType', other: 'Any', **kwargs: 'Any') -> 'ColumnElement[Any]'
self_group(self, against: 'Optional[OperatorType]' = None) -> 'ColumnElement[Any]'
shares_lineage(self, othercolumn: 'ColumnElement[Any]') -> 'bool' Return True if the given :class:`_expression.ColumnElement` [extrait de shares_lineage.__doc__]

Méthodes héritées de la classe DQLDMLClauseElement

__subclasshook__

Méthodes héritées de la classe ClauseElement

__bool__, __getstate__, __repr__, compare, params, unique_params

Méthodes héritées de la classe CompilerElement

__str__, compile

Méthodes héritées de la classe HasCopyInternals

__init_subclass__

Méthodes héritées de la classe HasMemoized

memoized_attribute, memoized_instancemethod

Méthodes héritées de la classe HasTraverseInternals

get_children

Méthodes héritées de la classe ColumnOperators

all_, any_, asc, between, bitwise_and, bitwise_lshift, bitwise_not, bitwise_or, bitwise_rshift, bitwise_xor, collate, concat, contains, desc, distinct, endswith, icontains, iendswith, ilike, in_, is_, is_distinct_from, is_not, is_not_distinct_from, isnot, isnot_distinct_from, istartswith, like, match, not_ilike, not_in, not_like, notilike, notin_, notlike, nulls_first, nulls_last, nullsfirst, nullslast, regexp_match, regexp_replace, startswith

Méthodes héritées de la classe Operators

__sa_operate__, bool_op, op

Méthodes héritées de la classe object

__delattr__, __dir__, __format__, __getattribute__, __hash__, __reduce__, __reduce_ex__, __setattr__, __sizeof__

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