title: Sqlite insert in Flask
body: <p>I have an html template that includes some Python code and HTML templates. This is a sample below.<br></p>
  
  <p>Python:</p>
  
  <pre><code>cur1 = g.db.execute('select ID from Students')
  students = [dict(ID=row[0]) for row in cur1.fetchall()]
  cur2 = g.db.execute('select ID from Quizzes')
  quizzes = [dict(ID=row[0]) for row in cur2.fetchall()]
  if request.method == 'POST':
      if not session.get('logged_in'):
          abort(401)
      g.db.execute('insert into Results (quiz,student,grade) values '\
                   '(?,?,?)',[request.form['Quiz'],
                              request.form['Student'],
                              request.form['grade']])
      g.db.commit()
      return render_template('add_result.html',students=students,quizzes=quizzes)
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>  &lt;form action="{{ url_for('add_result') }}" method=post&gt;
    &lt;select name="Quiz"&gt;
      {% for quiz in quizzes %}
      &lt;option value="{{ quiz }}"&gt;{{ quiz.ID }}&lt;/option&gt;
      {% endfor %}
    &lt;/select&gt;
    &lt;select name="Student"&gt;
      {% for student in students %}
      &lt;option value="{{ student }}"&gt;{{ student.ID }}&lt;/option&gt;
      {% endfor %}
    &lt;/select&gt;
    &lt;input type="number" name="grade"&gt;
    &lt;input type="submit" value=Submit&gt;
    &lt;/form&gt;
  </code></pre>
  
  <p>which outputs the drop down lists in the format I want (integers), however, for example, say the values quiz #1 and student #1 with a grade of 100, they are then input into SQLite as </p>
  
  <blockquote>
    <p>(2, u"{'ID': 1}", u"{'ID': 1}", 100.0)</p>
  </blockquote>
  
  <p>How can I get this output?:</p>
  
  <blockquote>
    <p>(2,1,1,100.0)</p>
  </blockquote>