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 :

Module « sqlalchemy »

Classe « Index »

Informations générales

Héritage

builtins.object
    Traversible
builtins.object
    SchemaEventTarget
        SchemaItem
    builtins.object
        ColumnCollectionMixin
    builtins.object
        DialectKWArgs
            Index

Définition

class Index(DialectKWArgs, ColumnCollectionMixin, SchemaItem):

Description [extrait de Index.__doc__]

A table-level INDEX.

    Defines a composite (one or more column) INDEX.

    E.g.::

        sometable = Table("sometable", metadata,
                        Column("name", String(50)),
                        Column("address", String(100))
                    )

        Index("some_index", sometable.c.name)

    For a no-frills, single column index, adding
    :class:`_schema.Column` also supports ``index=True``::

        sometable = Table("sometable", metadata,
                        Column("name", String(50), index=True)
                    )

    For a composite index, multiple columns can be specified::

        Index("some_index", sometable.c.name, sometable.c.address)

    Functional indexes are supported as well, typically by using the
    :data:`.func` construct in conjunction with table-bound
    :class:`_schema.Column` objects::

        Index("some_index", func.lower(sometable.c.name))

    An :class:`.Index` can also be manually associated with a
    :class:`_schema.Table`,
    either through inline declaration or using
    :meth:`_schema.Table.append_constraint`.  When this approach is used,
    the names
    of the indexed columns can be specified as strings::

        Table("sometable", metadata,
                        Column("name", String(50)),
                        Column("address", String(100)),
                        Index("some_index", "name", "address")
                )

    To support functional or expression-based indexes in this form, the
    :func:`_expression.text` construct may be used::

        from sqlalchemy import text

        Table("sometable", metadata,
                        Column("name", String(50)),
                        Column("address", String(100)),
                        Index("some_index", text("lower(name)"))
                )

    .. versionadded:: 0.9.5 the :func:`_expression.text`
       construct may be used to
       specify :class:`.Index` expressions, provided the :class:`.Index`
       is explicitly associated with the :class:`_schema.Table`.


    .. seealso::

        :ref:`schema_indexes` - General information on :class:`.Index`.

        :ref:`postgresql_indexes` - PostgreSQL-specific options available for
        the :class:`.Index` construct.

        :ref:`mysql_indexes` - MySQL-specific options available for the
        :class:`.Index` construct.

        :ref:`mssql_indexes` - MSSQL-specific options available for the
        :class:`.Index` construct.

    

Constructeur(s)

Signature du constructeur Description
__init__(self, name, *expressions, **kw) Construct an index object. [extrait de __init__.__doc__]

Liste des attributs statiques

Nom de l'attribut Valeur
columnsNone
create_drop_stringify_dialectdefault
dialect_kwargs<sqlalchemy.util.langhelpers.memoized_property object at 0x7f40cbecc6d0>
dialect_options<sqlalchemy.util.langhelpers.memoized_property object at 0x7f40cbece8c0>
dispatch<sqlalchemy.event.base.DDLEventsDispatch object at 0x7f40cbc2af40>
info<sqlalchemy.util.langhelpers.memoized_property object at 0x7f40cbc85d20>

Liste des propriétés

Nom de la propriétéDescription
bindReturn the connectable associated with this Index. [extrait de __doc__]
kwargsA synonym for :attr:`.DialectKWArgs.dialect_kwargs`. [extrait de __doc__]

Liste des opérateurs

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

__eq__, __ge__, __gt__, __le__, __lt__, __ne__

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
__repr__(self)
create(self, bind=None, checkfirst=False) Issue a ``CREATE`` statement for this [extrait de create.__doc__]
drop(self, bind=None, checkfirst=False) Issue a ``DROP`` statement for this [extrait de drop.__doc__]

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

__init_subclass__, __subclasshook__

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

__class_getitem__, get_children

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

argument_for

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

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