Created
May 3, 2020 17:02
-
-
Save blacklight/7ce8731b35bcfb79dee5ee3caa0b8a5d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from platypush.utils import run | |
def main(): | |
db_engine = 'postgresql+pg8000://user:password@db_ip_address/covid19' | |
# List of country codes you want to monitor | |
countries = ['nl', 'it', 'us', 'es', 'gb', 'cn', 'fr', 'ru'] | |
# Pull the historical data | |
data = [ | |
{ | |
'country': row['Country'], | |
'confirmed': row['Confirmed'] or 0, | |
'deaths': row['Deaths'] or 0, | |
'recovered': row['Recovered'] or 0, | |
'report_date': row['Date'][:-10], | |
} | |
for row in run('covid19.data', country=countries) | |
] | |
# Insert the rows in the database | |
run('db.insert', table='tmp_covid19_data', engine=db_engine, records=data) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment