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


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. Note that index names are supposed to be unique with a given schema so the table name doesn’t have to be part of the keylist, but has been retained to facilitate certain operations.

class pyrseas.dbobject.index.Index(name, schema, table, description, unique=False, access_method='btree', keys=[], predicate=None, tablespace=None, cluster=False, keyexprs=None, defn=None, oid=None)

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

An index is identified by its schema name and index name. However, at this time, Pyrseas uses the triple schema-table-index names as the identifier.


Return comma-separated list of key column names and qualifiers


Convert an index definition to a YAML-suitable format

Index.create(obj, *args, **kwargs)

Return a SQL statement to CREATE the index

Returns:SQL statements

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.


Generate SQL to drop the current index

Returns:list of SQL statements

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

  • table – table owning the indexes
  • inindexes – YAML map defining the indexes