gaoluyang
15 小时以前 e40a608ef9bf51db294d8eefada6a8e2e80cebca
1
2
3
4
5
6
7
8
9
10
11
12
13
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)
with c.cursor() as q:
 q.execute('SELECT * FROM mes_qc_indicator WHERE deleted=0 ORDER BY id');rows=q.fetchall()
 (P/'preview.json').write_text(json.dumps(rows,ensure_ascii=False,default=str,indent=2),encoding='utf8')
 print('总数',len(rows),'备注种类',json.dumps(list(dict.fromkeys(x['remark'] for x in rows if x['remark'])),ensure_ascii=False))
 print('检验项',json.dumps([{k:x[k] for k in ['id','name','tool','result_specification']} for x in rows],ensure_ascii=False))
c.close()