30 lines
774 B
Python
30 lines
774 B
Python
from datetime import datetime
|
|
from sqlalchemy import Column
|
|
from sqlalchemy import DateTime
|
|
from sqlalchemy import Integer
|
|
from sqlalchemy import String
|
|
from .base import Base
|
|
|
|
|
|
class HistoricWeather(Base):
|
|
__tablename__ = 'historic_weather'
|
|
DATE_FORMAT = "%Y-%m-%d"
|
|
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
city = Column(String(100))
|
|
temperature = Column(Integer)
|
|
condition = Column(String(25))
|
|
humidity = Column(Integer)
|
|
date = Column(DateTime)
|
|
|
|
|
|
def to_dict(self):
|
|
return {
|
|
"city": self.city,
|
|
"temperature": self.temperature,
|
|
"condition": self.condition,
|
|
"humidity": self.humidity,
|
|
"date": datetime.strftime(self.date, self.DATE_FORMAT)
|
|
}
|