From 31bcbc51ddeddcbcfdf919c523baa84221b058a6 Mon Sep 17 00:00:00 2001 From: Julien Riou Date: Thu, 18 Feb 2021 17:32:49 +0100 Subject: [PATCH] Commit more often Signed-off-by: Julien Riou --- db.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/db.py b/db.py index 2c51293..4610c65 100644 --- a/db.py +++ b/db.py @@ -72,8 +72,8 @@ def upsert_shops(names): if not shop_database: logger.info(f'{shop} added') session.add(shop) - session.commit() - logger.debug('transaction committed') + session.commit() + logger.debug('transaction committed') except exc.SQLAlchemyError: logger.exception('cannot commit transaction') finally: @@ -111,8 +111,8 @@ def upsert_products(products, notifier=None): Product.available: product.available, Product.url: product.url, Product.tweet_id: tweet_id, Product.updated_at: now}) logger.info(f'{product} updated') - session.commit() - logger.debug('transaction committed') + session.commit() + logger.debug('transaction committed') except exc.SQLAlchemyError: logger.exception('cannot commit transaction') finally: