Using session.merge instead of session.add to handle insert/update logic

This commit is contained in:
Fabio Manganiello 2020-04-30 00:59:33 +02:00
parent 3bb4c4434c
commit 77e302cd4b

View file

@ -77,11 +77,11 @@ class Covid19Backend(Backend):
update_time=update_time,
))
session.add(Covid19Update(country=summary['CountryCode'],
confirmed=summary['TotalConfirmed'],
deaths=summary['TotalDeaths'],
recovered=summary['TotalRecovered'],
last_updated_at=update_time))
session.merge(Covid19Update(country=summary['CountryCode'],
confirmed=summary['TotalConfirmed'],
deaths=summary['TotalDeaths'],
recovered=summary['TotalRecovered'],
last_updated_at=update_time))
def loop(self):
# noinspection PyUnresolvedReferences