Archived
1
0
Fork 0

Commit more often

Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
Julien Riou 2021-02-18 17:32:49 +01:00
parent e424b3bf98
commit 31bcbc51dd
No known key found for this signature in database
GPG key ID: FF42D23B580C89F7

8
db.py
View file

@ -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: