lundi 26 octobre 2015

Query sqlite using flask routing

I am trying to query my sqlite database using flask routing such as

@app.route ('/movies/genres/<name>/')
def test( name = None):
g.db = connect_db()
cur = g.db.execute('select * from movies where category = ?', [name])
movies = [dict(id=row[0], movie_name=row[1])  for row in cur.fetchall()]
g.db.close()
return render_template ('test.html', movies=movies, name=name)

The routing does work but the page doesn't display any data from the database. Can anyone see what the issue might be?

Aucun commentaire:

Enregistrer un commentaire