import sys,json,re from pathlib import Path P=Path(__file__).parent sys.stdout.reconfigure(encoding='utf8') sys.path.insert(0,str(P.parent/'iqc-import-20261012/deps')) import pymysql c=pymysql.connect(host='36.213.150.237',port=10000,user='root',password=sys.stdin.readline().strip(),database='mom-hm',charset='utf8mb4',cursorclass=pymysql.cursors.DictCursor) s={} with c.cursor() as q: q.execute("SELECT table_name FROM information_schema.columns WHERE table_schema=DATABASE() AND column_name='remark' AND (table_name LIKE 'crm_%' OR table_name IN ('erp_sale_order','erp_sale_order_items')) ORDER BY table_name");tabs=[x['TABLE_NAME'] for x in q.fetchall()] for t in tabs: q.execute('SHOW COLUMNS FROM '+t);cols=[x['Field'] for x in q.fetchall()] if not {'id','deleted','update_time'}<=set(cols):continue q.execute('SELECT * FROM '+t+' WHERE deleted=0 ORDER BY id');rows=q.fetchall();s[t]=rows remarks=list(dict.fromkeys(x['remark'] for x in rows if x['remark'])) print(t,'有效记录',len(rows),'有备注',sum(bool(x['remark']) for x in rows),'不同备注',len(remarks));print(json.dumps(remarks[:12],ensure_ascii=False,default=str)) (P/'preview.json').write_text(json.dumps(s,ensure_ascii=False,default=str,indent=2),encoding='utf8') c.close()