def singleton_sql_value(engine, query_string):
with engine.connect() as conn:
result = conn.execute(query_string)
- return result.next()[0]
+ return result.first()[0]
# %%
# %%
-total_uk_deaths = singleton_sql_value(engine, 'select sum(new_deaths) from uk_data')
+# total_uk_deaths = singleton_sql_value(engine, 'select (cum_deaths) from uk_data')
+total_uk_deaths = singleton_sql_value(engine,
+ 'select cum_deaths from uk_data where cum_deaths > 0 order by date desc limit 1')
deaths_in_past_month = singleton_sql_value(engine, f"select sum(new_deaths) from uk_data where date > '{thirty_days_ago.isoformat()}'")
cases_in_past_month = singleton_sql_value(engine, f"select sum(new_cases) from uk_data where date > '{thirty_days_ago.isoformat()}'")
total_uk_deaths, deaths_in_past_month, cases_in_past_month
f.write('\n')
f.write('![Cases and deaths in last 60 days](cases_and_deaths_last_60_days.png)\n')
f.write('\n')
- f.write('![Deaths compared to past five years](deaths-radar-2021.png)\n')
+ f.write('![Deaths compared to past five years](deaths_radar_2021.png)\n')
f.write('\n')
# %%