#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Dec  3 11:12:31 2021

@author: rico
"""
import os
import sys
sys.path.append(os.path.dirname(os.getcwd()))
from ESCore.ES import ES_Client
import datetime
import pandas as pd
import pymssql
import pymysql
from public import zgc_api,Index
from SimilarCharactor.string_similarity import similarity_cn,similarity_en


#上传数据字典补充数据
def ComplicatedDataDict(path):
    
    #创建新产品库链接
    conn_zi_new = pymssql.connect(host='123.56.115.207', user='zgcprice3311',password='zgcprice20200628',database= 'ZI_NEW',autocommit=True)
    cursor_zi_new = conn_zi_new.cursor()
    
    df = pd.read_excel(path)
    process_index = 0
    index_ = Index()
    for index,row in df.iterrows():
        
        try:
            print(index_(process_index,len(df)-1), end='%')
        except:
            print(index_(process_index,1), end='%')
        process_index+=1
    
        cursor_zi_new.execute(f"update ShuJuZiDian_Cfg set stdvalue = '{row['stdvalue']}',simplevalue = '{row['simplevalue']}' where id = {row['id']}")
       
        
    conn_zi_new.close()
    

#更新数据字典
path = '/Users/rico/Downloads/台式机数据字典补充(3)(1).xlsx'
ComplicatedDataDict(path)
