buildingmotif.database.table_connection#
Classes
|
Controls interaction with the database. |
- class TableConnection(engine: Engine, bm)[source]#
Controls interaction with the database.
- create_db_model(name: str, description: str = '') DBModel [source]#
Create a database model.
- Parameters:
name (str) – name of DBModel
description (str) – description of the model
- Returns:
DBModel
- Return type:
- get_all_db_models() List[DBModel] [source]#
Get all database models.
- Returns:
all DBModels
- Return type:
List[DBModel]
- get_db_model(id: int) DBModel [source]#
Get database model by id.
- Parameters:
id (int) – id of DBModel
- Returns:
DBModel
- Return type:
- get_db_model_by_name(name: str) DBModel [source]#
Get database model by name.
- Parameters:
name (str) – name of DBModel
- Returns:
DBModel
- Return type:
- update_db_model_name(id: int, name: str) None [source]#
Update database model name.
- Parameters:
id (int) – id of DBModel
name (str) – new name
- update_db_model_description(id: int, description: str) None [source]#
Update database model description.
- Parameters:
id (int) – id of DBModel
description (str) – new description
- delete_db_model(id: int) None [source]#
Delete database model.
- Parameters:
id (int) – id of deleted DBModel
- create_db_shape_collection() DBShapeCollection [source]#
Create a database shape collection.
- Returns:
DBShapeCollection
- Return type:
- get_all_db_shape_collections() List[DBShapeCollection] [source]#
Get all database shape collections.
- Returns:
all DBShapeCollections
- Return type:
List[DBShapeCollection]
- get_db_shape_collection(id: int) DBShapeCollection [source]#
Get database shape collection by id.
- Parameters:
id (int) – id of DBShapeCollection
- Returns:
DBShapeCollection
- Return type:
- delete_db_shape_collection(id: int) None [source]#
Delete database shape collection.
- Parameters:
id (int) – id of deleted DBShapeCollection
- create_db_library(name: str) DBLibrary [source]#
Create database library.
- Parameters:
name (str) – name of DBLibrary
- Returns:
DBLibrary
- Return type:
- get_all_db_libraries() List[DBLibrary] [source]#
Get all database libraries.
- Returns:
all DBLibrary
- Return type:
List[DBLibrary]
- get_db_library(id: int) DBLibrary [source]#
Get database library by id.
- Parameters:
id (int) – id of DBLibrary
- Returns:
DBLibrary
- Return type:
- get_db_library_by_name(name: str) DBLibrary [source]#
Get database library by name.
- Parameters:
name (str) – name of DBLibrary
- Returns:
DBLibrary
- Return type:
- update_db_library_name(id: int, name: str) None [source]#
Update database library name.
- Parameters:
id (int) – id of DBLibrary
name (str) – new name
- delete_db_library(id: int) None [source]#
Delete database library.
- Parameters:
id (int) – id of deleted DBLibrary
- create_db_template(name: str, library_id: int) DBTemplate [source]#
Create database template.
- Parameters:
name (str) – name of DBTemplate
library_id (int) – id of the template’s library
- Returns:
DBTemplate
- Return type:
- get_all_db_templates() List[DBTemplate] [source]#
Get all database templates.
- Returns:
all DBTemplate
- Return type:
List[DBTemplate]
- get_db_template(id: int) DBTemplate [source]#
Get database template by id.
- Parameters:
id (int) – id of DBTemplate
- Returns:
DBTemplate
- Return type:
- get_db_template_by_name(name: str) DBTemplate [source]#
Get database template by name.
- Parameters:
name (str) – name of DBTemplate
- Returns:
DBTemplate
- Return type:
- get_library_defining_db_template(id: int) DBLibrary [source]#
Returns the library defining the given template.
- Parameters:
id (int) – id of template
- Returns:
DBLibrary
- Return type:
- get_db_template_dependencies(id: int) Tuple[DepsAssociation, ...] [source]#
Get a template’s dependencies and its arguments.
If you don’t need the arguments, consider using :py:method:`dataclasses.template.get_dependencies`.
- Parameters:
id (int) – template id
- Returns:
tuple of tuple, where each tuple has the dependant_id and it’s args
- Return type:
tuple[tuple[int, list[str]]]
- update_db_template_name(id: int, name: str) None [source]#
Update database template name.
- Parameters:
id (int) – id of DBTemplate
name (str) – new name
- update_db_template_optional_args(id: int, optional_args: List[str]) None [source]#
Update database template optional arguments.
- Parameters:
id (int) – id of DBTemplate
optional_args – new list of optional_args
- add_template_dependency_preliminary(template_id: int, dependency_id: int, args: Dict[str, str])[source]#
Creates a preliminary dependency between two templates. This dependency is preliminary because the bindings between the dependent/dependency templates are not validated. This serves to populate the directed acyclic graph of dependencies between templates before the parameter bindings are checked. This ensures that all of the parameters for a template and those in its dependencies can all be identified and used as part of the parameter binding check. The upshot of this process is dependencies between two templates can refer to parameters in a template or its dependencies. This is necessary to support templates that contain many nested components that refer to each other (such as the s223:mapsTo property).
Important: Be sure to run “check_all_template_dependencies” to ensure all of your templates. will work as you expect!
- Parameters:
template_id (int) – dependant template id
dependency_id (int) – dependency template id
args (Dict[str, str]) – mapping of dependency params to dependant params
- Raises:
ValueError – if all dependee required_params not in args
ValueError – if dependant and dependency template don’t share a
- check_all_template_dependencies()[source]#
Verifies that all template dependencies have valid references to the parameters in the dependency or (recursively) its dependencies. Raises an exception if any issues are found. Checks all templates in the database.
- check_template_dependency_relationship(dep: DepsAssociation)[source]#
Verify that the dependency between two templates is well-formed. This involves a series of checks: - existence of the dependent and dependency templates is performed during the :py:method:`database.template_connection.`add_template_dependency_preliminary` method - the args keys appear in the dependency, or recursively in a template that is a dependency of the named dependency - the args values appear in the dependent template - there is a ‘name’ parameter in the dependent template
- Parameters:
dep (DepsAssociation) – the dependency object to check
- Raises:
ValueError – if all dependee required_params not in args
ValueError – if dependant and dependency template don’t share a library
- delete_template_dependency(template_id: int, dependency_id: int)[source]#
Delete dependency between two templates.
- Parameters:
template_id (int) – dependant template id
dependency_id (int) – dependency template id