TableSpec¶
- 
class lsst.daf.butler.TableSpec(fields: NamedValueSet[FieldSpec], unique: Set[Tuple[str, ...]], foreignKeys: List[ForeignKeySpec], sql: Optional[str] = None, doc: Optional[str] = None)¶
- Bases: - object- A struct-like class used to define a logical Registry table (which may also be implemented in the database as a view). - Attributes Summary - doc- Documentation for the table. - sql- A SQL SELECT statement that can be used to define this logical table as a view. - Methods Summary - addForeignKeys(tableName, schema)- Add SQLAlchemy foreign key constraints for this table to the corresponding entry in the given schema. - fromConfig(config, *args, **kwds)- isView()- Return - Trueif this logical table should be implemented as some kind of view.- toSqlAlchemy(tableName, schema)- Construct a SQLAlchemy - Tableor- Viewcorresponding to this specification.- Attributes Documentation - 
doc= None¶
- Documentation for the table. 
 - 
sql= None¶
- A SQL SELECT statement that can be used to define this logical table as a view. - Should be - Noneif this table’s contents is not defined in terms of other tables.
 - Methods Documentation - 
addForeignKeys(tableName: str, schema: lsst.daf.butler.core.schema.Schema)¶
- Add SQLAlchemy foreign key constraints for this table to the corresponding entry in the given schema. - Parameters: - Notes - This must be called after - toSqlAlchemyhas been called on all tables in the schema.
 - 
classmethod fromConfig(config, *args, **kwds)¶
 - 
toSqlAlchemy(tableName: str, schema: lsst.daf.butler.core.schema.Schema) → Union[sqlalchemy.sql.schema.Table, lsst.daf.butler.core.views.View]¶
- Construct a SQLAlchemy - Tableor- Viewcorresponding to this specification.- This does not emit the actual DDL statements that would create the table or view in the database; it merely creates a SQLAlchemy representation of the table or view. - Parameters: - Returns: - table : sqlalchemy.TableorView
- A SQLAlchemy object representing the logical table. 
 - Notes - This does not add foreign key constraints, as all tables must be created (in the SQLAlchemy metadata sense) before foreign keys can safely be created. - addForeignKeysmust be called to complete this process.
- table : 
 
-