import xlrd
import pymssql
conn = pymssql.connect(server='127.0.0.1:1433', user='sa', password='qwe123', database='yb')
cursor = conn.cursor()
chart = xlrd.open_workbook("d:\\xiyao20220905.xlsx")
sheet = chart.sheet_by_name("xiyao")
for i in range(1,sheet.nrows):
l = sheet.row_values(i)
a=l[0].rstrip()
b=l[1].rstrip()
c=l[2].rstrip()
d=l[3].rstrip()
e=l[4].rstrip()
sql="insert into t_110703_zjb (FL,XMID,XMMC,QYMC,PZZH) values('%s','%s','%s','%s','%s')"%(a,b,c,d,e)
cursor.execute(sqlNonQuery)
conn.commit()
print('success')
最终只插入了一行,请哪位大神帮我看下错误在哪,跪谢
import pymssql
conn = pymssql.connect(server='127.0.0.1:1433', user='sa', password='qwe123', database='yb')
cursor = conn.cursor()
chart = xlrd.open_workbook("d:\\xiyao20220905.xlsx")
sheet = chart.sheet_by_name("xiyao")
for i in range(1,sheet.nrows):
l = sheet.row_values(i)
a=l[0].rstrip()
b=l[1].rstrip()
c=l[2].rstrip()
d=l[3].rstrip()
e=l[4].rstrip()
sql="insert into t_110703_zjb (FL,XMID,XMMC,QYMC,PZZH) values('%s','%s','%s','%s','%s')"%(a,b,c,d,e)
cursor.execute(sqlNonQuery)
conn.commit()
print('success')
最终只插入了一行,请哪位大神帮我看下错误在哪,跪谢