class documentation

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.

Method __init__ Construct an index object.
Method __repr__ Undocumented
Method create Issue a ``CREATE`` statement for this :class:`.Index`, using the given :class:`.Connection` or :class:`.Engine`` for connectivity.
Method drop Issue a ``DROP`` statement for this :class:`.Index`, using the given :class:`.Connection` or :class:`.Engine` for connectivity.
Class Variable __visit_name__ Undocumented
Instance Variable expressions Undocumented
Instance Variable info Info dictionary associated with the object, allowing user-defined data to be associated with this :class:`.SchemaItem`.
Instance Variable name Undocumented
Instance Variable table Undocumented
Instance Variable unique Undocumented
Method _set_parent Associate with this SchemaEvent's parent object.
Instance Variable _table_bound_expressions Undocumented

Inherited from DialectKWArgs:

Class Method argument_for Add a new kind of dialect-specific keyword argument for this class.
Class Variable __slots__ Undocumented
Property dialect_kwargs A collection of keyword arguments specified as dialect-specific options to this construct.
Property dialect_options A collection of keyword arguments specified as dialect-specific options to this construct.
Property kwargs A synonym for :attr:`.DialectKWArgs.dialect_kwargs`.
Method _kw_reg_for_dialect_cls Undocumented
Method _validate_dialect_kwargs Undocumented
Class Variable _dialect_kwargs_traverse_internals Undocumented
Class Variable _kw_registry Undocumented

Inherited from ColumnCollectionMixin (via DialectKWArgs):

Property c Undocumented
Property columns Undocumented
Method _check_attach Undocumented
Method _col_expressions Undocumented
Method _set_parent_with_dispatch Undocumented
Class Variable _allow_multiple_tables Undocumented
Instance Variable _cols_wo_table Undocumented
Instance Variable _column_flag Undocumented
Instance Variable _columns Undocumented
Instance Variable _pending_colargs Undocumented

Inherited from HasConditionalDDL (via DialectKWArgs, ColumnCollectionMixin):

Method ddl_if apply a conditional DDL rule to this schema item.
Instance Variable _ddl_if Undocumented

Inherited from SchemaItem (via DialectKWArgs, ColumnCollectionMixin, HasConditionalDDL):

Class Variable create_drop_stringify_dialect Undocumented
Method _init_items Initialize the list of child items for this SchemaItem.
Method _schema_item_copy Undocumented
Class Variable _use_schema_map Undocumented

Inherited from SchemaEventTarget (via DialectKWArgs, ColumnCollectionMixin, HasConditionalDDL, SchemaItem):

Class Variable dispatch Undocumented

Inherited from Visitable (via DialectKWArgs, ColumnCollectionMixin, HasConditionalDDL, SchemaItem, SchemaEventTarget, EventTarget):

Method __class_getitem__ Undocumented
Method __init_subclass__ Undocumented
Class Method _generate_compiler_dispatch Undocumented
Method _compiler_dispatch Undocumented
Class Variable _original_compiler_dispatch Undocumented
def __init__(self, name: Optional[str], *expressions: _DDLColumnArgument, unique: bool = False, quote: Optional[bool] = None, info: Optional[_InfoType] = None, _table: Optional[Table] = None, _column_flag: bool = False, **dialect_kw: Any): (source)

Construct an index object. :param name: The name of the index :param \*expressions: Column expressions to include in the index. The expressions are normally instances of :class:`_schema.Column`, but may also be arbitrary SQL expressions which ultimately refer to a :class:`_schema.Column`. :param unique=False: Keyword only argument; if True, create a unique index. :param quote=None: Keyword only argument; whether to apply quoting to the name of the index. Works in the same manner as that of :paramref:`_schema.Column.quote`. :param info=None: Optional data dictionary which will be populated into the :attr:`.SchemaItem.info` attribute of this object. .. versionadded:: 1.0.0 :param \**dialect_kw: Additional keyword arguments not mentioned above are dialect specific, and passed in the form ``<dialectname>_<argname>``. See the documentation regarding an individual dialect at :ref:`dialect_toplevel` for detail on documented arguments.

def __repr__(self) -> str: (source)
def create(self, bind: _CreateDropBind, checkfirst: bool = False): (source)

Issue a ``CREATE`` statement for this :class:`.Index`, using the given :class:`.Connection` or :class:`.Engine`` for connectivity. .. seealso:: :meth:`_schema.MetaData.create_all`.

def drop(self, bind: _CreateDropBind, checkfirst: bool = False): (source)

Issue a ``DROP`` statement for this :class:`.Index`, using the given :class:`.Connection` or :class:`.Engine` for connectivity. .. seealso:: :meth:`_schema.MetaData.drop_all`.

expressions = (source)

Undocumented

Info dictionary associated with the object, allowing user-defined data to be associated with this :class:`.SchemaItem`. The dictionary is automatically generated when first accessed. It can also be specified in the constructor of some objects, such as :class:`_schema.Table` and :class:`_schema.Column`.

Undocumented

Undocumented

Undocumented

def _set_parent(self, parent: SchemaEventTarget, **kw: Any): (source)

Associate with this SchemaEvent's parent object.

_table_bound_expressions = (source)

Undocumented