feat: 从数据库转存到超表做count限制

This commit is contained in:
caoqianming 2024-07-16 14:50:50 +08:00
parent bf98ea8a48
commit d31cf4d143
1 changed files with 4 additions and 0 deletions

View File

@ -53,6 +53,10 @@ def db_insert_mplogx():
last_tag_id = config['enm'].get('last_tag_id', None)
if last_tag_id is None:
raise Exception("last_tag_id is None")
cursor.execute("select count(id) from tag_value where id > %s", (last_tag_id))
count = cursor.fetchone()[0]
if count > 400:
raise Exception("db inset count > 400")
cursor.execute(
"select id, val, tag_code, update_time from tag_value where id > %s order by id, update_time", (last_tag_id))
rows = cursor.fetchall() # 获取数据后保存至本地