1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| import sys,json
| 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)
| found=[]
| with c.cursor() as q:
| q.execute("SELECT table_name,column_name FROM information_schema.columns WHERE table_schema=DATABASE() AND (table_name LIKE 'mes_qc_%' OR table_name LIKE 'mes_pro_%' OR table_name LIKE 'mes_wm_%') AND data_type IN ('varchar','char','text','longtext','mediumtext') ORDER BY table_name,ordinal_position");cols=q.fetchall()
| for x in cols:
| t=x['TABLE_NAME'];col=x['COLUMN_NAME']
| if col in ['creator','updater']:continue
| q.execute('SELECT id,`'+col+'` value FROM `'+t+'` WHERE deleted=0 AND (`'+col+'` LIKE %s OR `'+col+'` LIKE %s OR `'+col+'` LIKE %s OR `'+col+'` LIKE %s)',('%演示%','%非真实%','%非实测%','%不是现场实测%'))
| rs=q.fetchall()
| if rs:
| found.append({'table':t,'column':col,'rows':rs});print(t,col,len(rs),json.dumps(rs[:12],ensure_ascii=False,default=str))
| (P/'display-labels-preview.json').write_text(json.dumps(found,ensure_ascii=False,default=str,indent=2),encoding='utf8')
| print('匹配总数',sum(len(x['rows']) for x in found))
| c.close()
|
|