2023-11-23 01:06:38 +01:00
|
|
|
from sqlalchemy import JSON, Column, DateTime, Float, Integer, ForeignKey, String
|
2023-11-20 01:46:01 +01:00
|
|
|
|
|
|
|
from . import Entity
|
|
|
|
|
|
|
|
|
|
|
|
class Weather(Entity):
|
|
|
|
"""
|
|
|
|
Weather entity.
|
|
|
|
"""
|
|
|
|
|
|
|
|
__tablename__ = 'weather'
|
|
|
|
|
|
|
|
id = Column(Integer, ForeignKey(Entity.id, ondelete='CASCADE'), primary_key=True)
|
|
|
|
|
|
|
|
summary = Column(String)
|
|
|
|
icon = Column(String)
|
2023-11-20 03:08:53 +01:00
|
|
|
image = Column(String)
|
2023-11-20 01:46:01 +01:00
|
|
|
precip_intensity = Column(Float)
|
|
|
|
precip_type = Column(String)
|
|
|
|
temperature = Column(Float)
|
|
|
|
apparent_temperature = Column(Float)
|
|
|
|
humidity = Column(Float)
|
|
|
|
pressure = Column(Float)
|
2023-11-20 03:08:53 +01:00
|
|
|
rain_chance = Column(Float)
|
2023-11-20 01:46:01 +01:00
|
|
|
wind_speed = Column(Float)
|
2023-11-20 03:08:53 +01:00
|
|
|
wind_direction = Column(String)
|
2023-11-20 01:46:01 +01:00
|
|
|
wind_gust = Column(Float)
|
|
|
|
cloud_cover = Column(Float)
|
|
|
|
visibility = Column(Float)
|
|
|
|
sunrise = Column(DateTime)
|
|
|
|
sunset = Column(DateTime)
|
|
|
|
units = Column(String)
|
|
|
|
|
|
|
|
__table_args__ = {'extend_existing': True}
|
|
|
|
__mapper_args__ = {
|
|
|
|
'polymorphic_identity': __tablename__,
|
|
|
|
}
|
2023-11-23 01:06:38 +01:00
|
|
|
|
|
|
|
|
|
|
|
class WeatherForecast(Entity):
|
|
|
|
"""
|
|
|
|
Weather forecast entity.
|
|
|
|
"""
|
|
|
|
|
|
|
|
__tablename__ = 'weather_forecast'
|
|
|
|
|
|
|
|
id = Column(Integer, ForeignKey(Entity.id, ondelete='CASCADE'), primary_key=True)
|
|
|
|
# forecast contains a list of serialized Weather entities
|
|
|
|
forecast = Column(JSON)
|
|
|
|
|
|
|
|
__table_args__ = {'extend_existing': True}
|
|
|
|
__mapper_args__ = {
|
|
|
|
'polymorphic_identity': __tablename__,
|
|
|
|
}
|