i'm trying to create a web app with bottle (python 3.4) to use pre-definite query from an sqlite db.
I don't know how to show, in the html page, the columns name.
the code for bottle.py is:
@route('/attivita')
def attivita():
conn = sqlite3.connect('database.db')
c = conn.cursor()
c.execute("SELECT ID_ATT, State FROM names",)
result1 = c.fetchall()
c.close()
output = template('query1', rows=result1)
return output
and the code into the html page is:
<table border="1">
%for row in rows:
%id, title = row
<tr>
%for col in row:
<td>{{col}}</td>
%end
<td><a href="/edit/{{id}}"> Edit</a></td>
</tr>
%end
</table>
Can someone help me?
Thanks a lot
Mauro
Aucun commentaire:
Enregistrer un commentaire