city_retrofit/exports/db_factory.py

33 lines
783 B
Python
Raw Normal View History

"""
DBFactory performs read related operations
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2022 Concordia CERC group
Project CoderPeter Yefi peteryefi@gmail.com
"""
from persistence import CityRepo
class DBFactory:
"""
DBFactory class
"""
def __init__(self, city, db_name, app_env):
self._city = city
self._city_repo = CityRepo(db_name=db_name, app_env=app_env)
def get_city(self, city_id):
"""
Retrieve a single city from postgres
:param city_id: the id of the city to get
"""
return self._city_repo.get_by_id(city_id)
def get_city_by_name(self, city_name):
"""
Retrieve a single city from postgres
:param city_name: the name of the city to get
"""
return self._city_repo.get_by_name(city_name)