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_md_workshop','mes_md_workstation','mes_md_workstation_machine','mes_md_workstation_worker','mes_md_workstation_tool','mes_wm_warehouse','mes_wm_warehouse_location','mes_wm_warehouse_area','mes_wm_barcode','mes_pro_process','system_dict_type','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() cond=" AND (type LIKE '%process_param%' OR type LIKE '%PROCESS_PARAM%')" if t=='system_dict_type' else (" AND (dict_type LIKE '%process_param%' OR dict_type LIKE '%PROCESS_PARAM%')" if t=='system_dict_data' else '') q.execute('SELECT * FROM '+t+' WHERE deleted=0'+cond+' ORDER BY id');s[t]=list(q.fetchall()) c.close() (P/'before-station-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 not in ['mes_wm_barcode','mes_pro_process','mes_wm_warehouse_area']:print(k,len(v),json.dumps(v[:12],ensure_ascii=False,default=str))