Skip to content

pyaccesskit.schema.indexes

pyaccesskit.schema.indexes

Index specifications.

PRIMARY_KEY_NAME module-attribute

PRIMARY_KEY_NAME = 'PrimaryKey'

The name Access gives primary-key indexes.

IndexField

Bases: SpecModel

One column of an index, optionally in descending order.

IndexSpec

Bases: SpecModel

An index on one or more columns.

Attributes:

Name Type Description
name str

Index name (Access names the primary key PrimaryKey).

fields Items[IndexField]

Indexed columns; plain strings are accepted (["LastName", "FirstName"]) as are ("Col", "desc") pairs.

primary bool

This is the table's primary key (implies unique and required).

unique bool

No two rows may have the same key.

required bool

Null values are not allowed in the indexed columns.

ignore_nulls bool

Rows with Null keys are left out of the index.

field_names property

field_names: tuple[str, ...]

The indexed column names, in order.

primary_key classmethod

primary_key(
    *columns: str, name: str = PRIMARY_KEY_NAME
) -> IndexSpec

A primary-key index on columns (named PrimaryKey like Access does).

on classmethod

on(
    name: str,
    *columns: str | tuple[str, str],
    unique: bool = False,
    **options: bool,
) -> IndexSpec

Convenience constructor: IndexSpec.on("ix_Name", "LastName", "FirstName", unique=True).