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?

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

.
May.25,2022

when you say timeout, you should mean http timeout. One is to extend the http timeout on your http server, and the other is to take import_xlsx as a different request and open a subprocess to handle


process excel and then use the new pymysql connection to query the database


insert a row at a time. This is not efficient

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b308fb-2bd16.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b308fb-2bd16.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?