34 lines
1.2 KiB
Python
34 lines
1.2 KiB
Python
"""
|
|
Model representation of a City
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|
Copyright © 2022 Concordia CERC group
|
|
Project Coder Peter Yefi peteryefi@gmail.com
|
|
"""
|
|
|
|
from sqlalchemy import Column, Integer, String, Sequence, Float
|
|
from persistence.db_config import Base
|
|
from sqlalchemy.orm import relationship
|
|
|
|
|
|
class City(Base):
|
|
"""A model representation of a city
|
|
|
|
Attributes:
|
|
name The name of the city.
|
|
uid A unique identifier for each city object
|
|
location The location of the building.
|
|
country_code The country where the city is located.
|
|
latitude The GPS latitude location of the city.
|
|
longitude The GPS longitude location of the city.
|
|
building A relationship for fetching all buildings in the city
|
|
"""
|
|
__tablename__ = "city"
|
|
id = Column(Integer, Sequence('city_id_seq'), primary_key=True)
|
|
uid = Column(String, nullable=False, unique=True)
|
|
name = Column(String, nullable=False)
|
|
time_zone = Column(String, nullable=True)
|
|
country_code = Column(String, nullable=False)
|
|
latitude = Column(Float)
|
|
longitude = Column(Float)
|
|
building = relationship('Building', backref='city', lazy=True, cascade="all, delete-orphan")
|