Indexes

The index module defines two classes, Index and IndexDict, derived from DbSchemaObject and DbObjectDict, respectively.

Index

Class Index is derived from DbSchemaObject and represents an index on a database table, other than a primary key or unique constraint index. Its keylist attributes are the schema name, the table name and the index name.

An Index has the following attributes: access_method, unique, and keycols.

class pyrseas.dbobject.index.Index(**attrs)

A physical index definition, other than a primary key or unique constraint index.

Index.key_expressions()

Return comma-separated list of key column names and qualifiers

Returns:string
Index.to_map()

Convert an index definition to a YAML-suitable format

Returns:dictionary
Index.create(obj, *args, **kwargs)

Return a SQL statement to CREATE the index

Returns:SQL statements
Index.diff_map(inindex)

Generate SQL to transform an existing index

Parameters:inindex – a YAML map defining the new index
Returns:list of SQL statements

Compares the index to an input index and generates SQL statements to transform it into the one represented by the input.

Index Dictionary

Class IndexDict is derived from DbObjectDict and represents the collection of indexes in a database.

class pyrseas.dbobject.index.IndexDict(dbconn=None)

The collection of indexes on tables in a database

IndexDict.from_map(table, inindexes)

Initialize the dictionary of indexes by converting the input map

Parameters:
  • table – table owning the indexes
  • inindexes – YAML map defining the indexes
IndexDict.diff_map(inindexes)

Generate SQL to transform existing indexes

Parameters:inindexes – a YAML map defining the new indexes
Returns:list of SQL statements

Compares the existing index definitions, as fetched from the catalogs, to the input map and generates SQL statements to transform the indexes accordingly.

Table Of Contents

Previous topic

Constraints

Next topic

Rules

This Page