3

In the buy function, the walkthrough video talk about implementing the code below when trying to retrieve the cash.:

result = db.execute("SELECT cash from users WHERE id=1")

But obviously this gets the cash from id=1 all the time, so how would I get the cash from the user that is currently logged in?

I'd been trying to play around trying to solve this for an hour without success, thanks.

my attempt:

result = db.execute("SELECT cash from users WHERE id=:id", id= session['user_id'])

This apparently doesn't return an integer, rather a list data type.

1 Answer 1

3

From the C$50Finance spec Hints re the execute method:

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.

You must log in to answer this question.

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