-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPARSE_Wh.py
More file actions
64 lines (58 loc) · 2.25 KB
/
PARSE_Wh.py
File metadata and controls
64 lines (58 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# -*- coding: utf-8 -*-
import pymssql
from openpyxl import load_workbook
'''
def run():
with pymssql.connect(host='10.1.246.1', user="sa", password="sasasa",database="CAPOL_Project") as conn:
cur=conn.cursor()
UserId=GetUserId(cur,'libina')
print(UserId)
AlterUserName(cur,UserId,'李斌2')
AlterLoginName(cur,UserId,'libin2')
conn.commit()
'''
conns={
'shenzhen':('10.1.246.1', "sa", "sasasa","CAPOL_Core"),
'shenzhen_old':('10.1.1.118', "sa", "hygj!@#456","TJA_Core"),
'guangzhou':('10.2.1.114', "sa", "hygj!@#456","CAPOL_Core"),
'hainan':('10.14.2.10',"sa", "hygj!@#456","CAPOL_Core"),
'changsha':('10.3.1.3',"sa", "abcd.1234","CAPOL_Core"),
'changsha_old':('10.3.1.3',"sa", "abcd.1234","TJA_Core"),
'shanghai':('10.6.1.15',"sa", "capol!@#456","CAPOL_Core"),
'shanghai_old':('10.6.1.15',"sa", "capol!@#456","TJA_Core"),
}
servers=['shenzhen',
'shenzhen_old',
'guangzhou',
'hainan',
'changsha',
'changsha_old',
'shanghai',
'shanghai_old']
file='D:\\3.xlsx'
def run():
res=Parse(file)
with pymssql.connect(host='10.1.42.131', user="sa", password="qfc23834358Q",database="test2") as conn:
cur=conn.cursor()
for item in res:
cur.execute(u"INSERT INTO WH_import(prjno,prjname,prjstatus,total_budget,wh_fillin,total_rate,chushe_rate,shigongtu_rate) values(%s,%s,%s,%s,%s,%s,%s,%s)",item)
conn.commit()
def Parse(file):
res=[]
workbook=load_workbook(file)
sheet_name=workbook.sheetnames[1]
worksheet=workbook[sheet_name]
row=3
while 1:
prjno,prjname,prjstatus=worksheet.cell(row, 2).value,worksheet.cell(row,3).value,worksheet.cell(row, 5).value
total_budget,wh_fillin=worksheet.cell(row, 6).value,worksheet.cell(row, 7).value
total_rate,chushe_rate=shigongtu_rateworksheet.cell(row, 8).value,worksheet.cell(row, 9).value,worksheet.cell(row, 10).value
row+=1
if not prjno:
break
else:
res.append((prjno,prjname,prjstatus,total_budget,wh_fillin,total_rate,chushe_rate,shigongtu_rate))
print((prjno,prjname,prjstatus,total_budget,wh_fillin,total_rate,chushe_rate,shigongtu_rate))
return res
if __name__=="__main__":
run()