SchemaBuilder

class lsst.daf.butler.SchemaBuilder

Bases: object

Builds a Schema step-by-step.

Attributes:
metadata : sqlalchemy.MetaData

The sqlalchemy schema description.

tables : dict

All created tables.

views : dict

All created views.

Attributes Summary

VALID_COLUMN_TYPES

Methods Summary

addColumn(table, columnDescription) Add a column to a table.
addForeignKeyConstraint(table, …) Add a ForeignKeyConstraint to a table.
addTable(tableName, tableDescription) Add a table to the schema metadata.
makeColumn(columnDescription) Make a Column entry for addition to a Table.
makeForeignKeyConstraint(constraintDescription) Make a ForeignKeyConstraint for addition to a Table.

Attributes Documentation

VALID_COLUMN_TYPES = {'blob': <class 'sqlalchemy.sql.sqltypes.LargeBinary'>, 'bool': <class 'sqlalchemy.sql.sqltypes.Boolean'>, 'datetime': <class 'sqlalchemy.sql.sqltypes.DateTime'>, 'float': <class 'sqlalchemy.sql.sqltypes.Float'>, 'int': <class 'sqlalchemy.sql.sqltypes.Integer'>, 'region': <class 'sqlalchemy.sql.sqltypes.LargeBinary'>, 'string': <class 'sqlalchemy.sql.sqltypes.String'>}

Methods Documentation

addColumn(table, columnDescription)

Add a column to a table.

Parameters:
table : sqlalchemy.Table, sqlalchemy.expression.TableClause or str

The table.

columnDescription : dict

Description of the column to be created. Should always contain: - name, descriptive name - type, valid column type May contain: - nullable, entry can be null - primary_key, mark this column as primary key - foreign_key, link to other table - doc, docstring

addForeignKeyConstraint(table, constraintDescription)

Add a ForeignKeyConstraint to a table.

Parameters:
table : sqlalchemy.Table or str

The table.

constraintDescription : dict

Description of the ForeignKeyConstraint to be created. Should always contain: - src, list of source column names - tgt, list of target column names

addTable(tableName, tableDescription)

Add a table to the schema metadata.

Parameters:
tableName : str

Key of the table.

tableDescription : dict

Table description.

Requires: - columns, a list of column descriptions - foreignKeys, a list of foreign-key constraint descriptions

Raises:
ValueError

If a table with the given name already exists.

makeColumn(columnDescription)

Make a Column entry for addition to a Table.

Parameters:
columnDescription : dict

Description of the column to be created. Should always contain: - name, descriptive name - type, valid column type May contain: - nullable, entry can be null - primary_key, mark this column as primary key - doc, docstring

Returns:
c : sqlalchemy.Column

The created Column entry.

Raises:
ValueError

If the column description contains unsupported arguments

makeForeignKeyConstraint(constraintDescription)

Make a ForeignKeyConstraint for addition to a Table.

Parameters:
constraintDescription : dict

Description of the ForeignKeyConstraint to be created. Should always contain: - src, list of source column names - tgt, list of target column names