flask is used in python. There is a page that uses xlrd to parse the data timeout of an 80,000 excel. Is there any way not to time out?
the code is as follows
@app.route("/import")
def import_xlsx():
-sharp
conn = pymysql.connect(host="192.168.10.2", port=3306, user="project", passwd="123456",
db="project") -sharp db:
-sharp cursor()
cursor = conn.cursor()
cursor.execute("truncate table project_info")
conn.commit()
cursor.execute("select * from project_attach_files where type=1");
result_one = cursor.fetchone()
print("")
print(result_one[2])
try:
ExcelFile = xlrd.open_workbook(r"." + result_one[2])
except Exception as e:
print(e)
-sharp print(ExcelFile.sheet_names())
sheet = ExcelFile.sheet_by_index(0)
-sharp print(sheet.nrows)
print(sheet.nrows);
cursor.execute("update project_attach_files set rows=" + str(sheet.nrows) + " where type=1");
conn.commit()
for i in range(sheet.nrows):
-sharp print(sheet.row_values(i))
data = sheet.row_values(i)
-sharp print(i)
-sharp print(data[1])
-sharp
if (i >= 5):
-sharp sql_insert = "insert into project_info(data_15,data_103,data_106) values(%s,%s,%s)",(data[4],data[6],data[7])
-sharp print(sql_insert)
-sharp
if data[14] == "" or data[14] == "":
data[133] = data[136]
-sharp ()
if (data[102] == ""):
data[102] = 0
-sharp
if (data[106] == ""):
data[106] = ""
-sharp
if (data[107] == ""):
data[107] = ""
-sharp
if (data[102] == ""):
data[102] = 0
-sharp
if (data[134] == ""):
data[134] = "1970-01-01"
-sharp
if (data[150] == ""):
data[150] = "0"
-sharp
if (data[164] == ""):
data[164] = ""
-sharp data_15 14
-sharp data_103 102
-sharp data_106 106
-sharp data_108 107
-sharp data_114 102
-sharp data_134 134
-sharp data_150 150
-sharp data_170 164
sql = """insert into project_info(data_15,data_103,data_106,data_108,data_114,data_134,data_150,data_170) values("%s","%s","%s","%s","%s","%s","%s","%s")""" % (
data[14], data[102], data[105], data[107], data[102], data[134], data[150], data[164])
cursor.execute(sql)
conn.commit()
return render_template("index.html", result_one=result_one[2])
I hope the boss can give me a way to deal with it or solve the problem without timeout, so that it can be analyzed smoothly. Thank you
.