title: How to execute two SQL commands from a single Flask route
body: <p>I am creating a web app with Flask. i have some tables in MySql database. all i want is to query one table data to a form and make some changes and insert that data back to another table. i have this route</p>
  
  <p>I made this changes to the code.</p>
  
  <pre><code>@app.route('/attendance', methods=  ['GET','POST'])
  def attendance():
      cur = connection.cursor()
      resultValue = cur.execute('''SELECT * FROM employee_data WHERE team = "ta15"''')
      if resultValue &gt; 0:
          userDetails = cur.fetchall()
          return render_template('take_attendance.html', userDetails=userDetails)
  
      if request.method == 'POST':
          userDetails = request.form
          oracle_id = userDetails.getlist('oracle_id')
          name = userDetails.getlist('name')
          status = userDetails.getlist('status')
          remark = userDetails.getlist('remark')
          stmt= "insert into attendance( id, name, status, remark) VALUES(%s, %s, %s, %s)"
          for i , id in enumerate(id):
              cur.excutemany(stmt, (id[i], name[i], status[i], remark[i]))
              cur.commit()
  </code></pre>
  
  <p>$And this is my Form</p>
  
  <pre><code>{% for data in userDetails %}
  
      &lt;tr&gt;
  
          &lt;td&gt;&lt;input type="text" name="oracle_id" id="oracle_id" size="6" value="{{data.oracle_id}}"&gt;&lt;/td&gt;
  
          &lt;td&gt;&lt;input type="text" name="name" id="name" size="20" value="{{data.name}}"&gt;&lt;/td&gt;
          &lt;td&gt;
          &lt;select name="status"&gt;
  
              &lt;option value="-1"&gt;select..&lt;/option&gt;
              &lt;option value="A"&gt;A&lt;/option&gt;
              &lt;option value="TR" selected&gt;1160&lt;/option&gt;
              &lt;option value="DR"&gt;1122&lt;/option&gt;
              &lt;option value="OR"&gt;1020&lt;/option&gt;
  
          &lt;/select&gt;&lt;/td&gt;
          &lt;td&gt;
          &lt;select name="shift"&gt;
              &lt;option value="-1"&gt;select..&lt;/option&gt;
              &lt;option value="Morning"&gt;7&lt;/option&gt;
              &lt;option value="Afternoon" selected&gt;15:00&lt;/option&gt;
          &lt;/select&gt;
          &lt;/td&gt;
          &lt;td&gt;&lt;textarea rows="1" cols="20" name="remark"&gt;&lt;/textarea&gt;&lt;/td&gt;
      &lt;/tr&gt;
  {% endfor %}
  </code></pre>
  
  <p>the query works fine by rendering the needed data to the form, the problem is it only Insert the first data on the form. Is there anyway i can fix this within a single route? Or is there a better way to do this?</p>