So when I try to make a history table, with some code that looks like
purchases = db.execute("SELECT stock, boughtsold, price, shares, time, user_id FROM history WHERE user_id = :user_id")
for purchase in purchases:
stock = purchase["stock"]
boughtsold = purchase["boughtsold"]
price = purchase['price']
shares = purchase['shares']
time = purchase['time']
userid = purchase["user_id"]
#else:
#stock = lookup(request.form.get("symbol"))
return render_template("history.html", stock=stock, boughtsold=boughtsold, price=price, shares=shares, time=time, userid=userid)
and html of
{% for purchase in purchases %}
<tr>
<td>{{purchase.boughtsold}}</td>
<td>{{purchase.stock}}</td>
<td>{{purchase.price}}</td>
<td>{{purchase.shares}}</td>
<td>{{purchase.time}}</td>
<td>{{purchase.userid}}</td>
</tr>
{% endfor %}
I get an error message with
File "/home/ubuntu/ide50/workspace/pset8/finance/application.py", line 162, in history
purchases = db.execute("SELECT stock, boughtsold, price, shares, time, user_id FROM history WHERE user_id = :user_id")
File "/usr/local/lib/python3.7/site-packages/cs50/flask.py", line 40, in _execute_after
return _execute_before(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/cs50/sql.py", line 177, in execute
raise RuntimeError("missing value for placeholder (:{})".format(name))
RuntimeError: missing value for placeholder (:user_id)
I'm not sure why this would be a problem. Where is the error? And how can I fix it? thanks for any help