Ejemplo n.º 1
0
 def db_save(item):
     db_session = DBFactory.get_db_session()
     db_item = DBItemService.copy_to_db(item)
     db_session.add(db_item)
     Statistic.db_item_success()
     logging.info(item.get_code + "已写入数据库缓存")
     return
Ejemplo n.º 2
0
 def db_commit(db_key):
     db_session = DBFactory.get_db_session()
     try:
         db_session.flush()
         db_session.commit()
         logging.info(db_key + "已提交数据库'keys_info'")
     except IntegrityError as e:
         db_session.rollback()
         Statistic.db_key_failed()
         logging.error("记录重复")
         logging.error(e)
     except Exception as e:
         Statistic.db_key_failed()
         logging.error("数据库写入失败!")
         logging.error(e)
Ejemplo n.º 3
0
 def db_update(db_key):
     db_session = DBFactory.get_db_session()
     db_session.merge(db_key)
     Statistic.db_key_success()
     logging.info(db_key.key_ + "已写入数据库缓存")
     return