DatabaseMetadata¶
- class lsst.daf.butler.registry.interfaces.DatabaseMetadata(namespace: str | None)¶
Bases:
objectWrapper around SqlAlchemy MetaData object to ensure threadsafety.
Notes
sqlalchemy.MetaDatais documented to be threadsafe for reads, but not with concurrent modifications. We add tables dynamically at runtime, and the MetaData object is shared by all Database instances sharing the same connection pool.Methods Summary
add_table(db, name, spec, **kwargs)Add a new table to the MetaData object, returning its sqlalchemy representation.
create_all(connection)Create all tables known to this MetaData object in the database.
get_table(name)Return the definition of a table that was previously added to this MetaData object.
remove_table(name)Remove a table that was previously added to this MetaData object.
Methods Documentation
- add_table(db: Database, name: str, spec: TableSpec, **kwargs: Any) Table¶
Add a new table to the MetaData object, returning its sqlalchemy representation. This does not physically create the table in the database – it only sets up its definition.
- Parameters:
- Returns:
- table
sqlalchemy.schema.Table The created table.
- table
- create_all(connection: Connection) None¶
Create all tables known to this MetaData object in the database. Same as
sqlalchemy.MetaData.create_all.- Parameters:
- connection
sqlalchemy.engine.connection Database connection that will be used to create tables.
- connection