#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 24 17:21:29 2021

@author: rico
"""


import pandas as pd
import pymssql
from public import Index

#上传数据字典补充数据
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/台式机数据字典补充(1).xlsx'
ComplicatedDataDict(path)



