From 98ec9561aa68f2796d82e8819cc9871f6ad36ab5 Mon Sep 17 00:00:00 2001 From: sanj <67624670+iodrift@users.noreply.github.com> Date: Thu, 25 Jul 2024 01:32:50 -0700 Subject: [PATCH] Auto-update: Thu Jul 25 01:32:50 PDT 2024 --- sijapi/classes.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sijapi/classes.py b/sijapi/classes.py index 73a584a..1f3caef 100644 --- a/sijapi/classes.py +++ b/sijapi/classes.py @@ -31,9 +31,9 @@ def warn(text: str): logger.warning(text) def err(text: str): logger.error(text) def crit(text: str): logger.critical(text) -TS_ID=os.getenv("TS_ID", "NULL") T = TypeVar('T', bound='Configuration') +TS_ID = os.environ.get('TS_ID') class Configuration(BaseModel): HOME: Path = Path.home() _dir_config: Optional['Configuration'] = None @@ -280,7 +280,10 @@ class APIConfig(BaseModel): @property def local_db(self): - return next((db for db in self.POOL if db['ts_id'] == TS_ID), None) + local_db = next((db for db in self.POOL if db['ts_id'] == TS_ID), None) + if local_db is None: + raise ValueError(f"No database configuration found for TS_ID: {TS_ID}") + return local_db @asynccontextmanager async def get_connection(self, pool_entry: Dict[str, Any] = None):