X-Git-Url: https://git.njae.me.uk/?p=covid19.git;a=blobdiff_plain;f=publish.py;h=82a3a25dd53b07bfb4f0f08d527032c21620b952;hp=8dd4b0d4da946baad0372de1495afa5ff3add313;hb=HEAD;hpb=15eaad40c32fd6ac6ce6457451f4933fb45890b0 diff --git a/publish.py b/publish.py index 8dd4b0d..82a3a25 100644 --- a/publish.py +++ b/publish.py @@ -36,7 +36,7 @@ COUNTRIES_FRIENDS = tuple('ITA GBR ESP BEL SVN MEX'.split()) 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] # %% @@ -52,7 +52,9 @@ thirty_days_ago = last_uk_date - datetime.timedelta(days=30) # %% -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 @@ -132,7 +134,7 @@ with open('covid_summary.md', 'a') as f: 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') # %%