2022-11-03 15:29:09 -04:00
|
|
|
"""
|
|
|
|
Base repository class to establish db connection
|
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|
|
|
Copyright © 2022 Concordia CERC group
|
|
|
|
Project Coder Peter Yefi peteryefi@gmail.com
|
|
|
|
"""
|
2023-05-17 17:10:30 -04:00
|
|
|
import logging
|
2022-11-03 15:29:09 -04:00
|
|
|
from sqlalchemy import create_engine
|
2023-05-18 12:29:28 -04:00
|
|
|
from hub.persistence.configuration import Configuration
|
|
|
|
|
2022-11-03 15:29:09 -04:00
|
|
|
|
2023-02-01 06:05:12 -05:00
|
|
|
class Repository:
|
2023-05-18 12:29:28 -04:00
|
|
|
"""
|
|
|
|
Base repository class to establish db connection
|
|
|
|
"""
|
2022-11-15 20:48:42 -05:00
|
|
|
|
2022-12-07 19:06:17 -05:00
|
|
|
def __init__(self, db_name, dotenv_path: str, app_env='TEST'):
|
|
|
|
try:
|
2023-02-01 06:05:12 -05:00
|
|
|
self.configuration = Configuration(db_name, dotenv_path, app_env)
|
2023-05-10 17:06:51 -04:00
|
|
|
self.engine = create_engine(self.configuration.connection_string)
|
2022-12-07 19:06:17 -05:00
|
|
|
except ValueError as err:
|
2023-05-18 12:29:28 -04:00
|
|
|
logging.error('Missing value for credentials: %s', err)
|