I want to post each and every key with value to a function in the Flask framework to store them in a MySQL database. Would I be able do it this way?
JQuery
$.ajax({
        type: "POST",
        url: "{{url_for('savedata')}}", // Function to send data
        data: sessionStorage.serializeArray(),
        success: function(data) {
            window.location.replace("/quit"); // Redirect to another page after saving data
        }
});
app.py
conn = mysql.connect()
cursor = conn.cursor()
@app.route("/savedata",methods=["POST"])
def savedata():
sql = "INSERT INTO data_table "
data = ""
for (var i = 0; i < sessionStorage.length; i++) {
    var item = sessionStorage.getItem(sessionStorage.key(i));
    data += "item " + "VARCHAR(255)"
}
sql += data
cursor.execute(sql)
 
     
    