Commit more often
Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
e424b3bf98
commit
31bcbc51dd
1 changed files with 4 additions and 4 deletions
8
db.py
8
db.py
|
@ -72,8 +72,8 @@ def upsert_shops(names):
|
||||||
if not shop_database:
|
if not shop_database:
|
||||||
logger.info(f'{shop} added')
|
logger.info(f'{shop} added')
|
||||||
session.add(shop)
|
session.add(shop)
|
||||||
session.commit()
|
session.commit()
|
||||||
logger.debug('transaction committed')
|
logger.debug('transaction committed')
|
||||||
except exc.SQLAlchemyError:
|
except exc.SQLAlchemyError:
|
||||||
logger.exception('cannot commit transaction')
|
logger.exception('cannot commit transaction')
|
||||||
finally:
|
finally:
|
||||||
|
@ -111,8 +111,8 @@ def upsert_products(products, notifier=None):
|
||||||
Product.available: product.available, Product.url: product.url,
|
Product.available: product.available, Product.url: product.url,
|
||||||
Product.tweet_id: tweet_id, Product.updated_at: now})
|
Product.tweet_id: tweet_id, Product.updated_at: now})
|
||||||
logger.info(f'{product} updated')
|
logger.info(f'{product} updated')
|
||||||
session.commit()
|
session.commit()
|
||||||
logger.debug('transaction committed')
|
logger.debug('transaction committed')
|
||||||
except exc.SQLAlchemyError:
|
except exc.SQLAlchemyError:
|
||||||
logger.exception('cannot commit transaction')
|
logger.exception('cannot commit transaction')
|
||||||
finally:
|
finally:
|
||||||
|
|
Reference in a new issue