-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
83 lines (73 loc) · 2.91 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
from sqlalchemy import create_engine, Column, Integer, String, Boolean, Date, SmallInteger, Float, Text
from sqlalchemy.engine import URL
from sqlalchemy.orm import declarative_base, sessionmaker
from functools import lru_cache
import config
@lru_cache()
def get_settings():
return config.Settings()
env = get_settings()
url = URL.create(
drivername=env.POSTGRES_DRIVERNMAE,
username=env.POSTGRES_USER,
password=env.POSTGRES_PASSWORD,
host=env.POSTGRES_HOSTNAME,
database=env.POSTGRES_DB,
port=5432
)
engine = create_engine(url)
Session = sessionmaker(bind=engine)
session = Session()
Base = declarative_base()
class Cases(Base):
__tablename__ = "cases"
id = Column(Integer, primary_key=True)
start_date = Column(Date)
end_date = Column(Date)
city = Column(String)
problem_description = Column(Text)
problem_population_density = Column(Integer)
problem_population = Column(Integer)
problem_age_distribution = Column(Float)
problem_start_number_of_active_cases = Column(Integer)
problem_end_number_of_active_cases = Column(Integer)
problem_start_number_of_icu_active_cases = Column(Integer)
problem_end_number_of_icu_active_cases = Column(Integer)
problem_start_number_of_deaths= Column(Integer)
problem_end_number_of_deaths = Column(Integer)
problem_vaccinated_population = Column(Integer)
problem_infection_rate = Column(Float)
problem_mortality_rate = Column(Float)
problem_average_temperature = Column(Float)
problem_average_humidity = Column(Float)
solution_description = Column(Text)
solution_lockdown_policy_level = Column(Integer)
solution_mask_policy_level = Column(Integer)
solution_vaccine_policy_level = Column(Integer)
solution_effectiveness = Column(Integer)
class Recommendation(Base):
__tablename__ = "recommendation"
id = Column(Integer, primary_key=True)
start_date = Column(Date)
end_date = Column(Date)
city = Column(String)
problem_description = Column(Text)
problem_population_density = Column(Integer)
problem_population = Column(Integer)
problem_age_distribution = Column(Float)
problem_start_number_of_active_cases = Column(Integer)
problem_end_number_of_active_cases = Column(Integer)
problem_start_number_of_icu_active_cases = Column(Integer)
problem_end_number_of_icu_active_cases = Column(Integer)
problem_start_number_of_deaths= Column(Integer)
problem_end_number_of_deaths = Column(Integer)
problem_vaccinated_population = Column(Integer)
problem_infection_rate = Column(Float)
problem_mortality_rate = Column(Float)
problem_average_temperature = Column(Float)
problem_average_humidity = Column(Float)
solution_description = Column(Text)
solution_lockdown_policy_level = Column(Integer)
solution_mask_policy_level = Column(Integer)
solution_vaccine_policy_level = Column(Integer)
Base.metadata.create_all(engine)