-
Notifications
You must be signed in to change notification settings - Fork 0
/
Excel.py
26 lines (19 loc) · 702 Bytes
/
Excel.py
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
#lines to import scores from excel to database
#database: allumni_record
from xlrd import open_workbook
import mysql.connector as mq
con=mq.connect(host="localhost",user="root",passwd="root",database="allumni_record")
cur=con.cursor()
def a():
wb=open_workbook("Allumni_file.xlsx")
s=wb.sheet_by_index(0)
for r in range(4,1000):
try:
d=[s.cell(r,8).value,s.cell(r,9).value,s.cell(r,10).value,s.cell(r,11).value,s.cell(r,12).value]
#print(d)
query="insert into students values ({},'{}',{},{},'{}')".format (d[0],d[1],d[2],d[3],d[4])
cur.execute(query)
con.commit()
except:
break
con.close()