Why this works:
cash = db.execute("SELECT cash FROM users WHERE id = :user_id", user_id = session["user_id"])
# Ensure user can afford the stock
if cash[0]["cash"] < share * quote["price"]:
return apology("Not enough money")
and this doesn't:
cash = db.execute("SELECT cash FROM users WHERE id = :user_id", user_id = session["user_id"])
# Ensure user can afford the stock
if cash < share * quote["price"]:
return apology("Not enough money")
I would like to understand how DB queries work in python. What is that "cash" variable stores? Isn't it the cash value for a user? (int)
Aucun commentaire:
Enregistrer un commentaire