Create table configuration that only creates a certain selection of tables
Currently, the create_tables
function creates all tables, but this may be confusing. Something like a typed dict can solve this, where we can specify a few use cases, where certain tables can be created. We should also be able to create custom configurations.
Something like this in a config.py:
from typing import TypedDict
class TableConfig(TypedDict):
entity: bool = False
asset: bool = False
taxonomy: bool = False
assetreference: bool = False
entityreference: bool = False
building: bool = False
damage: bool = False
STANDARD_CONFIG = TableConfig(entity=True, asset=True, taxonomy=True)
BASELINE_AS_STANDARD_CONFIG = TableConfig(entity=True, asset=True, taxonomy=True)
LOSS_CALCULATION = TableConfig(entity=True, asset=True, taxonomy=True, damage=True)
...
In the __init__.py
it should be:
...
from .config.py import TableConfig, STANDARD_CONFIG, BASELINE_CONFIG, LOSS_CALCULATION
__all__ = [..., "TableConfig", "STANDARD_CONFIG", "BASELINE_CONFIG", "LOSS_CALCULATION"]
We should be able to call the create_tables
function like:
import exposurelib
exposure_db = exposurelib.SpatiaLiteExposure('my_exposure.db')
exposure_db.create_tables(exposurelib.BASELINE_AS_STANDARD_CONFIG)
Edited by Laurens Oostwegel