so before I will do finance, I've wanted to build very simple site, where you could register, login and save in database how many times you've clicked a button. Problem is that I can't pass an argument, counter of clicks into site from database, when I perform this in application.py:

klik=db.execute("SELECT clicks FROM dane WHERE nick = :nick",nick=request.form["nick"])

return render_template("zabawa.html",klik=klik)

then in zabawa.html I have this line of code: {{klik}} in h2 paragraph

but the output on site is: [{'clicks': 0}] and I want only 0.

Table 'dane' has columns nick,password,email,id and clicks of course.

I would appreciate any kind of help.

1 Answer 1


The output looks like a list of dictionary objects, and in fact it is. From the Hints section of the spec:

If str is a SELECT, then execute returns a list of zero or more dict objects, inside of which are keys and values representing a table’s fields and cells, respectively.

Assuming the select query returns one row, you would want to pass klik[0]["clicks"] to the template.

  • Looks like I should read whole pset or watch Zamyla before even training, my bad. Thanks for the tip, it works perfectly now
    – KacMac
    Commented Sep 9, 2017 at 12:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .