Files
openclaw-config/workspace-finances/query_wlp_transfers.py
T

24 lines
901 B
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import json, pymysql
cfg = json.load(open('db_config.json'))
conn = pymysql.connect(host=cfg['host'], port=cfg['port'], user=cfg['user'],
password=str(cfg['password']), database=cfg['database'], charset='utf8mb4')
cur = conn.cursor()
# 汪礼平所有转账/红包类支出
cur.execute("""
SELECT recorded_date, amount, note FROM variable_expenses
WHERE member_id=1 AND (category='转账/红包' OR category LIKE '%红包%' OR note LIKE '%微信转账%' OR note LIKE '%微信红包%')
ORDER BY recorded_date
""")
rows = cur.fetchall()
print(f'共{len(rows)}笔转账/红包类记录:')
for r in rows:
print(f' {r[0]} {r[1]:>8.2f} {r[2]}')
print()
cur.execute("SELECT MIN(recorded_date), MAX(recorded_date) FROM variable_expenses WHERE member_id=1")
print('汪礼平支出日期范围:', cur.fetchone())
conn.close()