31 lines
650 B
Python
31 lines
650 B
Python
"""
|
|
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
|
|
"""
|
|
|
|
from persistence.db_config import BaseConfiguration
|
|
from sqlalchemy import create_engine
|
|
from sqlalchemy.orm import Session
|
|
|
|
|
|
class BaseRepo:
|
|
|
|
def __init__(self, db_name, app_env='TEST'):
|
|
config = BaseConfiguration(db_name, app_env)
|
|
engine = create_engine(config.conn_string())
|
|
self.config = config
|
|
self.session = Session(engine)
|
|
|
|
def __del__(self):
|
|
"""
|
|
Close database sessions
|
|
:return:
|
|
"""
|
|
self.session.close()
|
|
|
|
|
|
|
|
|