ForeignKeySpec

class lsst.daf.butler.ForeignKeySpec(table: str, source: Tuple[str, ...], target: Tuple[str, ...], onDelete: Optional[str] = None)

Bases: object

A struct-like class used to define a foreign key constraint in a logical Registry table.

Attributes Summary

onDelete

SQL clause indicating how to handle deletes to the target table.

Methods Summary

fromConfig(config, *args, **kwds)

toSqlAlchemy(tableName, schema)

Construct a SQLAlchemy ForeignKeyConstraint corresponding to this specification.

Attributes Documentation

onDelete = None

SQL clause indicating how to handle deletes to the target table.

If not None, should be either “SET NULL” or “CASCADE”.

Methods Documentation

classmethod fromConfig(config, *args, **kwds)
toSqlAlchemy(tableName: str, schema: lsst.daf.butler.core.schema.Schema) → sqlalchemy.sql.schema.ForeignKeyConstraint

Construct a SQLAlchemy ForeignKeyConstraint corresponding to this specification.

Parameters
tableNamestr

Name of the logical table to which this constraint belongs (the table for source columns).

schemaSchema

Object represening the full schema. May be modified in-place.

Returns
constraintsqlalchemy.ForeignKeyConstraint

SQLAlchemy version of the foreign key constraint.