StaticTablesContext

class lsst.daf.butler.registry.interfaces.StaticTablesContext(db: lsst.daf.butler.registry.interfaces._database.Database)

Bases: object

Helper class used to declare the static schema for a registry layer in a database.

An instance of this class is returned by Database.declareStaticTables, which should be the only way it should be constructed.

Methods Summary

addTable(name, spec) Add a new table to the schema, returning its sqlalchemy representation.
addTableTuple(specs, …]) Add a named tuple of tables to the schema, returning their SQLAlchemy representations in a named tuple of the same type.

Methods Documentation

addTable(name: str, spec: lsst.daf.butler.core.ddl.TableSpec) → sqlalchemy.sql.schema.Table

Add a new table to the schema, returning its sqlalchemy representation.

The new table may not actually be created until the end of the context created by Database.declareStaticTables, allowing tables to be declared in any order even in the presence of foreign key relationships.

addTableTuple(specs: Tuple[lsst.daf.butler.core.ddl.TableSpec, ...]) → Tuple[sqlalchemy.sql.schema.Table, ...]

Add a named tuple of tables to the schema, returning their SQLAlchemy representations in a named tuple of the same type.

The new tables may not actually be created until the end of the context created by Database.declareStaticTables, allowing tables to be declared in any order even in the presence of foreign key relationships.

Notes

specs must be an instance of a type created by collections.namedtuple, not just regular tuple, and the returned object is guaranteed to be the same. Because namedtuple is just a factory for type objects, not an actual type itself, we cannot represent this with type annotations.