title: How to hard delete a user from SQLite database using loops from Flask's View
body: <p>I've been working on a really simple,maybe trivial, flask application that manages users' credentials, like a sysadmin page (change username, password, privileges, email). </p>
  
  <p>Right now I've written the following code in HTML:</p>
  
  <pre><code>&lt;div id="signup-box" class="signup-box" style=" background-color:rgb(149, 202, 202); width: 60%;"&gt;       
            &lt;table class="table" style="background-color:#ffffff00;"&gt;
             &lt;thead &gt;
                  &lt;tr&gt;
                    &lt;th style="text-align:center; vertical-align:inherit;"&gt;Username&lt;/th&gt;
                    &lt;th style="text-align:center; vertical-align:inherit;"&gt;Role&lt;/th&gt;
                    &lt;th style="text-align:center; background-color:rgba(104, 159, 223, 0.384);"&gt;Control&lt;/th&gt;
                  &lt;tr&gt;
                &lt;/thead&gt;
                &lt;tbody&gt;                    
                    {% for i in range(0,lenUser) %}
                    &lt;tr class="tr"&gt;
  
                        &lt;td style="text-align:center; vertical-align:inherit;"&gt;{{ users[i] }}&lt;/td&gt;
                        &lt;td style="text-align:center; vertical-align:inherit;"&gt;{{ roles[i] }}&lt;/td&gt;
                        &lt;td style="text-align:center;"&gt;
                          &lt;button form="edit_form" type="submit" value="Edit" class="button is-warning is-focused" style="margin-right: 45px;"&gt;Edit User&lt;/button&gt;                                                           
                          &lt;button form="delete_form" type="submit" value="Delete" class="button is-danger is-focused" style="margin-right: 45px;"&gt;Delete User&lt;/button&gt;                                                                                       
                          &lt;form id="edit_form" action="{{ url_for('edit_user', id=users.id) }}" method="POST"&gt;
                            &lt;input type="hidden" name="_method" value="EDIT"&gt;                                                            
                          &lt;/form&gt;
                          &lt;form id="delete_form"action="{{ url_for('delete_user', id=users.id) }}" method="POST"&gt;
                            &lt;input type="hidden" name="_method" value="DELETE"&gt;                                                                                        
                          &lt;/form&gt;
                        &lt;/td&gt;                          
                    &lt;/tr&gt;
       {% endfor %}           
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>in Python:</p>
  
  <p>@app.route("/delete_user/")</p>
  
  <pre><code>def delete_user():
      if not session.get('logged_in'):
              return redirect(url_for('login'))
      con = sqlite3.connect('sqlite:///accounts.db')
      cur = con.cursor()
      cur.execute('DELETE FROM User WHERE id = "' +  request.args.get('id')+ '"')
      cur.commit()
      con.close()
      return flask.jsonify({'success':"True"})
  </code></pre>
  
  <p>And as a Python helper to fetch my users:</p>
  
  <pre><code>def fetch_users():
          with session_scope() as s:                                
                   usrs = s.query(tabledef.User.username).order_by(tabledef.User.username).all()
                   tblUsrs = df.from_records(usrs)                             
          return(tblUsrs)
  </code></pre>
  
  <p>Now, what it does is that it fetches my users as a dataframe and it outputs them row by row in my html table, which is what it was intended to do. But I also want to delete the specific user when I press the button "Delete" in the HTML page, right? Problem is that I can't seem to find a way to select the specific id of the user from the following lines:</p>
  
  <pre><code>&lt;form id="delete_form"action="{{ url_for('delete_user', id=users.id) }}" method="POST"&gt;
   &lt;input type="hidden" name="_method" value="DELETE"&gt; 
  &lt;/form&gt;
  </code></pre>
  
  <p>How can I fix that? Because it is in a loop and every time the string I get is that of the first line</p>