python-RuntimeError:没有这样的列:inf
发布时间:2022-04-18 18:30:27 394
相关标签: # node.js
我有一条路线,上面说错误在80号线上,但看起来一切正常。当我运行它时,它会显示RuntimeError:no-this-column:inf。我以前从未见过这个,所以有人有什么建议吗?
@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("/")
完整错误:文件“/工作区/97107415/财务/助手。“py”;,第34行,在“U函数返回f(*args,**kwargs)文件”中/Workspace/97107415/finance/app。“py”;,第80行,在buy db中。执行(“更新用户设置现金=?其中id=?”,newCash,uid)文件/usr/local/lib/python3。10/站点包/cs50/sql。“py”;,第27行,在decorator return f(*args,**kwargs)文件中/usr/local/lib/python3。10/站点包/cs50/sql。“py”;,第398行,执行raise RUNTIMERROR:没有这样的列:inf
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报