auto: sync OpenClaw config 2026-08-08 23:17
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import pymysql, json, collections
|
||||
cfg = json.load(open('db_config.json'))
|
||||
conn = pymysql.connect(host=cfg['host'], port=cfg['port'], user=cfg['user'],
|
||||
password=cfg.get('password'), database=cfg['database'], charset='utf8mb4')
|
||||
cur = conn.cursor()
|
||||
cur.execute("""SELECT id, amount, recorded_date, note FROM variable_expenses
|
||||
WHERE member_id=3 AND note LIKE '%[微信]%' AND recorded_date BETWEEN '2026-01-01' AND '2026-06-30'""")
|
||||
rows = cur.fetchall()
|
||||
old = [] # 历史格式 (前导空格格式 [微信] 类型 |)
|
||||
new = [] # 本次导入格式 [微信] 支出|
|
||||
for vid, a, d, n in rows:
|
||||
if n.startswith('[微信] 支出'):
|
||||
new.append((d.strftime('%Y-%m-%d'), round(float(a), 2), vid, n))
|
||||
else:
|
||||
old.append((d.strftime('%Y-%m-%d'), round(float(a), 2), vid, n))
|
||||
print(f"历史微信记录: {len(old)}笔 ¥{sum(x[1] for x in old):.2f}")
|
||||
print(f"本次导入: {len(new)}笔 ¥{sum(x[1] for x in new):.2f}")
|
||||
|
||||
new_set = {(t, a) for t, a, _, _ in new}
|
||||
old_set = {(t, a) for t, a, _, _ in old}
|
||||
overlap = new_set & old_set
|
||||
only_new = new_set - old_set
|
||||
only_old = old_set - new_set
|
||||
print(f"\n重叠(同日同金额,新旧都有): {len(overlap)}笔 ¥{sum(x[1] for x in new):.2f}")
|
||||
print(f"仅本次导入: {len(only_new)}笔")
|
||||
print(f"仅历史: {len(only_old)}笔")
|
||||
conn.close()
|
||||
Reference in New Issue
Block a user