From 77e302cd4b9ee1b81d7a2f830a948fb416e45a0f Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Thu, 30 Apr 2020 00:59:33 +0200 Subject: [PATCH] Using session.merge instead of session.add to handle insert/update logic --- platypush/backend/covid19.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/platypush/backend/covid19.py b/platypush/backend/covid19.py index 8bf3a88e..f1fa9679 100644 --- a/platypush/backend/covid19.py +++ b/platypush/backend/covid19.py @@ -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