#!/usr/bin/env python3 # -*- coding: utf-8 -*- """修正微信导入中明显归类错误的项""" import pymysql, json 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("""UPDATE variable_expenses SET category='教育培训' WHERE member_id=3 AND note LIKE '%[微信]%' AND note LIKE '%殷老师%'""") print("殷老师学费->教育培训:", cur.rowcount, "笔") # 众安车险 -> 保险 cur.execute("""UPDATE variable_expenses SET category='保险' WHERE member_id=3 AND note LIKE '%[微信]%' AND note LIKE '%众安%'""") print("众安车险->保险:", cur.rowcount, "笔") # 中国石油/汽油 -> 交通 cur.execute("""UPDATE variable_expenses SET category='交通' WHERE member_id=3 AND note LIKE '%[微信]%' AND (note LIKE '%中国石油%' OR note LIKE '%中国石化%' OR note LIKE '%加油站%' OR note LIKE '%昆仑%') AND category='其他'""") print("汽油->交通:", cur.rowcount, "笔") conn.commit() conn.close()