1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| import sys,json
| from pathlib import Path
| P=Path(__file__).parent
| 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,connect_timeout=10,read_timeout=60)
| s={}
| with c.cursor() as q:
| q.execute('SELECT DATABASE() db');assert q.fetchone()['db']=='mom-hm'
| for t in ['mes_pd_process_param','mes_pd_process_param_template','mes_pd_process_param_template_detail','mes_pro_process_param','mes_pro_route_process','mes_md_unit_measure','mdm_unit','mdm_unit_measure','system_dict_data']:
| q.execute('SELECT COUNT(*) n FROM information_schema.tables WHERE table_schema=DATABASE() AND table_name=%s',(t,))
| if not q.fetchone()['n']:continue
| q.execute('SHOW CREATE TABLE '+t);s[t+'_schema']=q.fetchone()
| q.execute('SELECT * FROM '+t+' WHERE deleted=0'+(" AND dict_type IN ('mes_pd_process_param_type','mes_pd_process_param_template_type','mes_pd_param_type','mes_pd_template_type')" if t=='system_dict_data' else '')+' ORDER BY id');s[t]=list(q.fetchall())
| c.close()
| (P/'before-parameter-snapshot.json').write_text(json.dumps(s,ensure_ascii=False,indent=2,default=str),encoding='utf8')
| for k,v in s.items():
| if isinstance(v,list) and k!='mes_pro_route_process':print(k,len(v),json.dumps(v[:15],ensure_ascii=False,default=str))
|
|