'RuntimeError: no such column: inf
I have this route and it says that the error is on line 80, but It all looks fine. When I run it, it says RuntimeError: no such column: inf. I have never seen this before, so does anyone have any tips?
@app.route("/buy", methods=["GET", "POST"])
@login_required
def buy():
# If method is get, go to the html file
if request.method == "GET":
return render_template("buy.html")
#declare global variables
#get the amount of shares
shares = int(request.form.get("shares"))
# get the symbol of the stock
sym = request.form.get("symbol")
# get the user id for the session
uid = session["user_id"]
# get the user cash by looking at their user id
userMoney = db.execute("SELECT cash FROM users WHERE id = :user_id", user_id = uid)[0]["cash"]
# lookup the stock symbol from the function in helpers.py
symbol = lookup(sym)
# get the purchase value of the stock and all the shares
purchaseVal = shares * symbol["price"]
# get the date & time to put it in the table
currentDate = datetime.datetime.now()
#check to make sure that all values exist
if not symbol:
return apology("That symbol doesn't exist")
if int(shares) < 0:
return apology("Only positive shares!")
# if userCash < int(purchaseVal):
# return apology("Not enough money to purchase!")
#get the new user cash after purchasing the stock
newCash = userMoney - purchaseVal
db.execute("UPDATE users SET cash = ? WHERE id = ?", newCash, uid)
#update the table
db.execute("INSERT INTO purchases (user_id, shares, symbol, price, date) VALUES(?, ?, ?, ?, ?)", uid, shares, sym, purchaseVal, currentDate)
# display a successful purchase message using flash function that was included above
flash("Successful!")
#redirect to home page after purchasing
return redirect("/")
Full error: File "/workspaces/97107415/finance/helpers.py", line 34, in decorated_function return f(*args, **kwargs) File "/workspaces/97107415/finance/app.py", line 80, in buy db.execute("UPDATE users SET cash = ? WHERE id = ?", newCash, uid) File "/usr/local/lib/python3.10/site-packages/cs50/sql.py", line 27, in decorator return f(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/cs50/sql.py", line 398, in execute raise e RuntimeError: no such column: inf
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
