title: Python and Flask, display data out of mysql DB on html page
body: <p>every time I try to display my data out of my MySQL database on a <code>html</code> page it will only show the first column of the record or only the name of the column itself.</p>
  <p>For example:</p>
  <p>MyDatabase</p>
  <p>db</p>
  <pre><code>id  names
  1   Harry
  2   Snape
  </code></pre>
  <p>main.py</p>
  <pre><code>@app.route(&quot;/db&quot;, methodes = [&quot;POST&quot;, &quot;GET&quot;])
  def db():
      if request.method == &quot;POST&quot;:
          cur = mysql.connection.cursor(MySQLdb.cursors.DictCursor)
          cur.execute(&quot;SELECT names FROM db WHERE id = 1&quot;)
          output = cur.fetchone()
          cur. close 
          return render_template(&quot;db.html&quot;, data = output)
      else:
          return render_template(&quot;db.html&quot;)
  </code></pre>
  <p>db.html</p>
  <pre><code>{% extends &quot;base.html&quot; %}
  {% block title %}db{% endblock %}
  
  {% block content %}
  &lt;form method=&quot;POST&quot;&gt;
  &lt;input type=&quot;submit&quot; value=&quot;show data&quot;&gt;
  &lt;/form&gt;
  
  &lt;!-- Output 1 --&gt;
  &lt;p&gt;{{data}}&lt;/p&gt;
  
  &lt;!-- Output 2 --&gt;
  {% for i in data %}
      &lt;p&gt;{{i}}&lt;/p&gt;
  {% endfor %}
  
  &lt;!-- Output 3 --&gt;
  {% for i in data %}
      &lt;p&gt;{{i[0]}}&lt;/p&gt;
  {% endfor %}
  
  {% endblock %}
  </code></pre>
  <p>Output 1 = {'names': 'Harry'}</p>
  <p>Output 2 = names</p>
  <p>Output 3 = n</p>
  <p>I just want to get the records, not the column name, how can I do this (<em>Output = Harry</em>)</p>
  <p>I am new to all this, I would be happy about a short explanation :)</p>