hub/persistence/repositories/CityRepo.py
2022-11-03 15:29:09 -04:00

29 lines
791 B
Python

"""
City repository with database CRUD operations
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2022 Concordia CERC group
Project Coder Peter Yefi peteryefi@gmail.com
"""
from city_model_structure.city import City
from persistence.models import City as ModelCity
from persistence import BaseRepo
class CityRepo(BaseRepo):
def __init__(self):
super().__init__()
def insert(self, city: City):
model_city = ModelCity()
model_city.uid = city.uid
model_city.name = city.name
model_city.longitude = city.longitude
model_city.latitude = city.latitude
model_city.country_code = city.country_code
model_city.time_zone = city.time_zone
self.session.add(model_city)
self.session.flush()
self.session.commit()
return model_city