title: select entries from database mysql in dropdown, python flask
body: <p>I want to select data from database table in MySQL. It is procedure in Python</p>
  
  <pre><code>@app.route('/formworkers.html')
  def formworkers(): 
  cursor = mysql.connection.cursor()
  cur = cursor.execute("SELECT ID_worker, surname FROM workers")
  return render_template('formworkers.html', workers0=cursor.fetchall())
  </code></pre>
  
  <p>And template in Jinja2</p>
  
  <pre><code>{% extends "layout.html" %}
      {% block body %}
      {% if session.logged_in %}
      &lt;form action="" method=post class=add-worker &gt;
        &lt;dl&gt;
          &lt;dt&gt;Surname:
          &lt;dd&gt;&lt;select name="worker0"&gt;
          {% for ID_pats, surname in workers0 %}
          &lt;option value="{{ ID_worker }}"&gt;{{ surname }}&lt;/option&gt;
          {% endfor %}
          &lt;/select&gt;
          &lt;br&gt;&lt;br&gt;
          &lt;dd&gt;&lt;input type=submit value="Submit"&gt;
        &lt;/dl&gt;
      &lt;/form&gt;
    {% endif %}
  {% endblock %}
  </code></pre>
  
  <p>But the dropdown list does not contain data (for example [Ivanov, Petrov, Sidorov]) from the database, it contain values [surname, surname, surname]. Thank you.</p>