lsst.dax.apdb g9290983e33+ffdc83c6f7
 
Loading...
Searching...
No Matches
lsst.dax.apdb.sql.apdbSqlSchema.ApdbSqlSchema Class Reference
Inheritance diagram for lsst.dax.apdb.sql.apdbSqlSchema.ApdbSqlSchema:
lsst.dax.apdb.apdbSchema.ApdbSchema

Public Member Functions

 __init__ (self, sqlalchemy.engine.Engine engine, str dia_object_index, str htm_index_column, str schema_file, str ss_schema_file, str prefix="", str|None namespace=None, bool enable_replica=False)
 
bool empty (self)
 
None makeSchema (self, bool drop=False)
 
sqlalchemy.schema.Table get_table (self, ApdbTables|ExtraTables table_enum)
 
bool check_column (self, ApdbTables|ExtraTables table_enum, str column)
 
list[sqlalchemy.schema.Column] get_apdb_columns (self, ApdbTables|ExtraTables table_enum)
 
bool replication_enabled (self)
 
- Public Member Functions inherited from lsst.dax.apdb.apdbSchema.ApdbSchema
 __init__ (self, str schema_file, str ss_schema_file)
 
type|str column_dtype (self, felis.datamodel.DataType|ExtraDataTypes felis_type)
 
VersionTuple schemaVersion (self)
 
bool has_mjd_timestamps (self)
 

Static Public Attributes

tuple pixel_id_tables = (ApdbTables.DiaObject, ApdbTables.DiaObjectLast, ApdbTables.DiaSource)
 

Protected Member Functions

Mapping[ApdbTables, schema_model.Table_make_apdb_tables (self, str mysql_engine="InnoDB")
 
Mapping[ExtraTables, schema_model.Table_make_extra_tables (self, Mapping[ApdbTables, schema_model.Table] apdb_tables)
 
list[schema_model.Column_replicaChunkColumns (self, ExtraTables table_enum, ApdbTables apdb_enum)
 
list[schema_model.Index_replicaChunkIndices (self, ExtraTables table_enum, Mapping[str, schema_model.Column] column_map)
 
list[schema_model.Constraint_replicaChunkConstraints (self, ExtraTables table_enum, schema_model.Table apdb_table, schema_model.Table parent_table, Mapping[str, schema_model.Column] column_map)
 
- Protected Member Functions inherited from lsst.dax.apdb.apdbSchema.ApdbSchema
tuple[Mapping[ApdbTables, Table], VersionTuple|None] _buildSchemas (cls, str schema_file)
 

Protected Attributes

 _engine = engine
 
 _dia_object_index = dia_object_index
 
 _htm_index_column = htm_index_column
 
 _prefix = prefix
 
 _enable_replica = enable_replica
 
 _metadata = sqlalchemy.schema.MetaData(schema=namespace)
 
dict _apdb_tables
 
dict _extra_tables
 
bool|None _has_replica_chunks = None
 
bool|None _metadata_check = None
 
- Protected Attributes inherited from lsst.dax.apdb.apdbSchema.ApdbSchema
tuple[Mapping[ApdbTables, Table], VersionTuple|None] _schemaVersion = self._buildSchemas(schema_file)
 

Additional Inherited Members

- Public Attributes inherited from lsst.dax.apdb.apdbSchema.ApdbSchema
 tableSchemas
 

Detailed Description

Class for management of APDB schema.

Attributes
----------
objects : `sqlalchemy.Table`
    DiaObject table instance
objects_last : `sqlalchemy.Table`
    DiaObjectLast table instance, may be None
sources : `sqlalchemy.Table`
    DiaSource table instance
forcedSources : `sqlalchemy.Table`
    DiaForcedSource table instance
replication_enabled : `bool`
    If true then schema has tables for replication chunks.

Parameters
----------
engine : `sqlalchemy.engine.Engine`
    SQLAlchemy engine instance
dia_object_index : `str`
    Indexing mode for DiaObject table, see `ApdbSqlConfig.dia_object_index`
    for details.
htm_index_column : `str`
    Name of a HTM index column for DiaObject and DiaSource tables.
schema_file : `str`
    Location of the YAML file with APDB schema.
ss_schema_file : `str`
    Location of the YAML file with SSP schema.
prefix : `str`, optional
    Prefix to add to all schema elements.
namespace : `str`, optional
    Namespace (or schema name) to use for all APDB tables.
enable_replica : `bool`, optional
    If `True` then use additional tables for replica chunks.

Member Function Documentation

◆ _make_apdb_tables()

Mapping[ApdbTables, schema_model.Table] lsst.dax.apdb.sql.apdbSqlSchema.ApdbSqlSchema._make_apdb_tables ( self,
str mysql_engine = "InnoDB" )
protected
Generate schema for regular tables.

Parameters
----------
mysql_engine : `str`, optional
    MySQL engine type to use for new tables.

◆ _make_extra_tables()

Mapping[ExtraTables, schema_model.Table] lsst.dax.apdb.sql.apdbSqlSchema.ApdbSqlSchema._make_extra_tables ( self,
Mapping[ApdbTables, schema_model.Table] apdb_tables )
protected
Generate schema for insert ID tables.

◆ _replicaChunkColumns()

list[schema_model.Column] lsst.dax.apdb.sql.apdbSqlSchema.ApdbSqlSchema._replicaChunkColumns ( self,
ExtraTables table_enum,
ApdbTables apdb_enum )
protected
Return list of columns for replica chunks tables.

◆ _replicaChunkConstraints()

list[schema_model.Constraint] lsst.dax.apdb.sql.apdbSqlSchema.ApdbSqlSchema._replicaChunkConstraints ( self,
ExtraTables table_enum,
schema_model.Table apdb_table,
schema_model.Table parent_table,
Mapping[str, schema_model.Column] column_map )
protected
Return set of constraints for replica chunk table.

◆ _replicaChunkIndices()

list[schema_model.Index] lsst.dax.apdb.sql.apdbSqlSchema.ApdbSqlSchema._replicaChunkIndices ( self,
ExtraTables table_enum,
Mapping[str, schema_model.Column] column_map )
protected
Return set of indices for replica chunk table.

◆ check_column()

bool lsst.dax.apdb.sql.apdbSqlSchema.ApdbSqlSchema.check_column ( self,
ApdbTables | ExtraTables table_enum,
str column )
Check for the existence of the column in a given table, checking is
done against database, not APDB schema.

Parameters
----------
table_enum : `ApdbTables` or `ExtraTables`
    Table to check for a column.
column : `str`
    Name of the column to check.

Returns
-------
exists : `bool`
    True if column exists, False otherwise.

◆ empty()

bool lsst.dax.apdb.sql.apdbSqlSchema.ApdbSqlSchema.empty ( self)
Return True if database schema is empty.

Returns
-------
empty : `bool`
    `True` if none of the required APDB tables exist in the database,
    `False` if all required tables exist.

Raises
------
InconsistentSchemaError
    Raised when some of the required tables exist but not all.

◆ get_apdb_columns()

list[sqlalchemy.schema.Column] lsst.dax.apdb.sql.apdbSqlSchema.ApdbSqlSchema.get_apdb_columns ( self,
ApdbTables | ExtraTables table_enum )
Return list of columns defined for a table in APDB schema.

Returned list excludes columns that are implementation-specific, e.g.
``pixelId`` column is not include in the returned list.

Parameters
----------
table_enum : `ApdbTables` or `ExtraTables`
    Type of table.

Returns
-------
table : `list` [`sqlalchemy.schema.Column`]
    Table instance.

Raises
------
ValueError
    Raised if ``table_enum`` is not valid for this database.

◆ get_table()

sqlalchemy.schema.Table lsst.dax.apdb.sql.apdbSqlSchema.ApdbSqlSchema.get_table ( self,
ApdbTables | ExtraTables table_enum )
Return SQLAlchemy table instance for a specified table type/enum.

Parameters
----------
table_enum : `ApdbTables` or `ExtraTables`
    Type of table to return.

Returns
-------
table : `sqlalchemy.schema.Table`
    Table instance.

Raises
------
ValueError
    Raised if ``table_enum`` is not valid for this database.

◆ makeSchema()

None lsst.dax.apdb.sql.apdbSqlSchema.ApdbSqlSchema.makeSchema ( self,
bool drop = False )
Create or re-create all tables.

Parameters
----------
drop : `bool`, optional
    If True then drop tables before creating new ones.

◆ replication_enabled()

bool lsst.dax.apdb.sql.apdbSqlSchema.ApdbSqlSchema.replication_enabled ( self)
True if replication is enabled (`bool`).

Member Data Documentation

◆ _apdb_tables

dict lsst.dax.apdb.sql.apdbSqlSchema.ApdbSqlSchema._apdb_tables
protected
Initial value:
= {
apdb_enum: id_to_table[table_model.id] for apdb_enum, table_model in apdb_tables.items()
}

◆ _extra_tables

dict lsst.dax.apdb.sql.apdbSqlSchema.ApdbSqlSchema._extra_tables
protected
Initial value:
= {
extra_enum: id_to_table[table_model.id] for extra_enum, table_model in extra_tables.items()
}

The documentation for this class was generated from the following file: