import pymysql
import xlrd
import datetime

from xlrd import xldate_as_datetime
from xlrd import xldate_as_tuple

import time

book=xlrd.open_workbook('data.xlsx')
sheet = book.sheet_by_index(0)
conn = pymysql.connect(
host='localhost',
user='root',
passwd='123456',
db='funddata',
port=3306,
charset='utf8'
)
cur = conn.cursor()

sql = "insert into jingzhi(date,161005,163417,163402) values (%s,%s,%s,%s)"
#从 0开始
for r in range(1,sheet.nrows):

a=sheet.cell(r,0).value
date = xlrd.xldate_as_datetime(a,0).__format__("%Y-%m-%d")
l1 = sheet.cell(r,1).value
l2 = sheet.cell(r,2).value
l3 = sheet.cell(r,3).value
value = (date,l1,l2,l3)

cur.execute(sql,value)
conn.commit()

cur.close()
conn.close()