title: Creating an HTML table with database values in Flask
body: <p>I want to display a table showing the values of three fields for each of the units in a table. Some assistance with creating the dictionary from the database and passing objects to the template would be greatly appreciated.</p>
  
  <pre><code>@app.route('/')
  def index(row):
      unit_count = Units.query.count()
      unit = Units.query.filter_by(id=row).first()
      rows = [] # Unsure how to define rows from Units db table
      return render_template('table_overview.html', title='Overview', rows=rows, unit=unit)
  </code></pre>
  
  <pre class="lang-html prettyprint-override"><code>{% for row in rows %}
  &lt;tr&gt;
      &lt;td&gt;{{ row.unit.idnum }}&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;{{ row.unit.product_code }}&lt;/td&gt;
      &lt;td bgcolor="{{ row.unit.stat_colour }}"&gt;{{ row.unit.unit_status }}&lt;/td&gt;
  &lt;/tr&gt;
  {% endfor %}
  </code></pre>