import sys,json from pathlib import Path sys.path.insert(0,str(Path(__file__).parent/'deps')) import openpyxl,pymysql P=Path(__file__).parent source=Path('D:/WechatRecord/xwechat_files/wxid_vmeut7wztkbp22_1546/temp/RWTemp/2026-10/c40afdcfa98e2b4561823e6babbefa33/来料检验单导入-已填充(1).xls') w=openpyxl.load_workbook(source.open('rb'),data_only=True) sheets=[] for s in w.worksheets: rows=[] for row in s: rows.append([c.value.isoformat(sep=' ') if hasattr(c.value,'hour') else c.value for c in row]) sheets.append({'name':s.title,'rows':rows}) (P/'source.json').write_text(json.dumps(sheets,ensure_ascii=False,indent=2),encoding='utf8') print('Source:',[(s['name'],len(s['rows'])) for s in sheets]) for s in sheets:print(s['rows'][:4]) c=pymysql.connect(host='36.213.150.237',port=10000,user='root',password=sys.stdin.readline().strip(),database='mom-hm',charset='utf8mb4',connect_timeout=10,read_timeout=45,cursorclass=pymysql.cursors.DictCursor) out={} with c.cursor() as q: for t in ['mes_qc_iqc','mes_qc_iqc_line','mes_qc_template','mes_qc_template_item','mes_qc_template_indicator','mes_qc_indicator','mes_md_item','mdm_item','mdm_unit_measure','mdm_item_category','system_users','system_dict_data']: q.execute('SHOW CREATE TABLE `'+t+'`');out[t+'_schema']=q.fetchone() q.execute('SELECT * FROM `'+t+'` WHERE deleted=0');out[t]=q.fetchall() (P/'remote-snapshot.json').write_text(json.dumps(out,ensure_ascii=False,default=str,indent=2),encoding='utf8') print('Remote snapshot:',{k:len(v) for k,v in out.items() if isinstance(v,list)}) c.close()