SchemaBuilder¶
- 
class lsst.daf.butler.SchemaBuilder(config, limited=False)¶
- Bases: - object- Builds a Schema step-by-step. - Parameters: - config : SchemaConfig
- Configuration to parse. 
- limited : bool
- If - True, ignore tables, views, and associated foreign keys whose config descriptions include a “limited” key set to- False.
 - Attributes: - 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. - isIncluded(name)- Return True if the named table or view should be included in this schema. - isView(name)- Return True if the named table should be added / has been added as a view. - makeColumn(columnDescription)- Make a Column entry for addition to a Table. - normalizeForeignKeyConstraint(…)- Convert configuration for a ForeignKeyConstraint to standard form and return the target 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'>, 'hash': <class 'lsst.daf.butler.core.schema.Base64Bytes'>, '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,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
- length, length of the field
- nbytes, length of decoded string (only for type=='hash')
- doc, docstring
 
 
- table : 
 - 
addForeignKeyConstraint(table, constraintDescription)¶
- Add a ForeignKeyConstraint to a table. - If the table or the ForeignKeyConstraint’s target are views, or should not be included in this schema (because it is limited), does nothing. - Parameters: 
 - 
addTable(tableName, tableDescription)¶
- Add a table to the schema metadata. - Parameters: - Raises: - ValueError
- If a table with the given name already exists. 
 
 - 
isIncluded(name)¶
- Return True if the named table or view should be included in this schema. - Parameters: - name : str
- Name of a table or view. Does not need to have been added. 
 - Returns: - included : bool
- Whether the table or view should be included in the schema. 
 
- name : 
 - 
isView(name)¶
- Return True if the named table should be added / has been added as a view. - Parameters: - name : str
- Name of a table or view. Does not need to have been added. 
 - Returns: - view : bool
- Whether the table should be added / has been added as a view. 
 
- name : 
 - 
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 - length, length of the field - nbytes, length of decoded string (only for - type=='hash') - doc, docstring
 - Returns: - c : sqlalchemy.Column
- The created - Columnentry.
 - Raises: - ValueError
- If the column description contains unsupported arguments 
 
- columnDescription : 
 - 
normalizeForeignKeyConstraint(constraintDescription)¶
- Convert configuration for a ForeignKeyConstraint to standard form and return the target table. - Parameters: - constraintDescription : dict
- Description of the ForeignKeyConstraint to be created. Should always contain: - src, list of source column names or single source column name.
- tgt, list of (table-qualified) target column names or single target column name.
 - May also contain: - onDelete, one of “SET NULL” or “CASCADE”.
 
 - Returns: 
- constraintDescription : 
 
- config :