添加数据库异常判断

This commit is contained in:
workpc 2024-12-03 14:57:47 +08:00
parent 08c10b19b9
commit 7099e71b5c

View File

@ -139,6 +139,7 @@ def predict_main():
sqlitedb.create_table('most_model', columns="ds datetime, most_common_model TEXT") sqlitedb.create_table('most_model', columns="ds datetime, most_common_model TEXT")
sqlitedb.insert_data('most_model', (datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'), most_common_model,), columns=('ds', 'most_common_model',)) sqlitedb.insert_data('most_model', (datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'), most_common_model,), columns=('ds', 'most_common_model',))
try:
if is_weekday: if is_weekday:
logger.info('今天是周一,更新预测模型') logger.info('今天是周一,更新预测模型')
# 上传预警信息到数据库 # 上传预警信息到数据库
@ -157,6 +158,8 @@ def predict_main():
else: else:
warning_data_df['id'] = range(1, 1 + len(warning_data_df)) warning_data_df['id'] = range(1, 1 + len(warning_data_df))
warning_data_df.to_sql(table_name, con=engine, if_exists='append', index=False) warning_data_df.to_sql(table_name, con=engine, if_exists='append', index=False)
except:
logger.info('上传预警信息到数据库失败')
if is_corr: if is_corr: