simdb.database.database module¶
-
class simdb.database.database.Database(db_type: DBMS, scopefunc=
None, **kwargs)[source]¶ Bases:
objectClass to wrap the database access.
- delete_simulation(sim_ref: str) Simulation[source]¶
Delete the specified simulation from the database.
- engine : Engine¶
- get_file(file_uuid_str: str) File[source]¶
Get the specified file from the database.
- get_metadata(sim_ref: str, name: str) list[str][source]¶
Get all the metadata for the given simulation with the given key.
- get_simulation(sim_ref: str) Simulation[source]¶
Get the specified simulation from the database.
- get_simulation_children(simulation: Simulation) list[dict][source]¶
- get_simulation_children_ref(simulation: Simulation) list[SimulationReference][source]¶
- get_simulation_parents(simulation: Simulation) list[dict][source]¶
- get_simulation_parents_ref(simulation: Simulation) list[SimulationReference][source]¶
- insert_simulation(simulation: Simulation) None[source]¶
Insert the given simulation into the database.
- Parameters:¶
- simulation: Simulation¶
The Simulation to insert.
- Returns:¶
None
- list_files() list[File][source]¶
Return a list of all the files stored in the database.
- Returns:¶
A list of Files.
-
list_simulation_data(meta_keys: list[str] | None =
None, limit: int =0, page: int =1, sort_by: str ='', sort_asc: bool =False) tuple[int, list[dict]][source]¶ Return a list of all the simulations stored in the database.
- Returns:¶
A tuple of (total_count, list of simulation data dicts).
-
list_simulations(meta_keys: list[str] | None =
None, limit: int =0) list[Simulation][source]¶ Return a list of all the simulations stored in the database.
- Returns:¶
A list of Simulations.
- query_meta(constraints: list[tuple[str, str, QueryType]]) list[Simulation][source]¶
Query the metadata and return matching simulations.
- Returns:¶
- exception simdb.database.database.DatabaseError[source]¶
Bases:
RuntimeError
- exception simdb.database.database.DatabaseOutdatedError[source]¶
Bases:
DatabaseError
- exception simdb.database.database.DatabaseUninitializedError[source]¶
Bases:
DatabaseError
-
class simdb.database.database.Session(session_factory, scopefunc=
None)[source]¶ Bases:
scoped_session
- simdb.database.database.check_migrations(engine) str[source]¶
Check that the database is up-to-date with the latest Alembic migration.
Raises
DatabaseUninitializedErrorif the database has not been initialised at all (i.e. thealembic_versiontable is absent), orDatabaseOutdatedErrorif the database schema is behind the head revision.