#python #sql #flask
#python #sql #flask
Вопрос:
у меня возникла проблема, упомянутая в названии вопроса, при запуске фреймворка flask из python. возможно, синтаксическая ошибка, но я не могу в этом разобраться
это код:
# do the transaction
else:
# sustract stocks value from cash and update users table
current_user["cash"] = current_user["cash"] - final_price
db.execute("UPDATE users SET cash = :cash WHERE id = :id", cash = current_user["cash"], id = current_user["id"])
# query database to know if current user already have at least one of the requested shares
share_holder = dict(db.execute("SELECT * FROM stocks WHERE owner = :owner AND symbol = :symbol", owner = current_user["username"], symbol = symbol))
# if user doesn't have any of this particular shares
if not share_holder:
db.execute("INSERT INTO stocks (symbol, owner, amount, users_id) VALUES (:symbol, :owner, :amount, :users_id)", symbol = symbol, owner = current_user["username"], amount = shares, users_id = current_user["id"])
share_holder.clear()
return render_template("buy.html")
# if user have at least one share already
else:
new_shares_amount = int(share_holder["amount"]) shares
db.execute("UPDATE stocks SET amount = :amount WHERE id = :id", amount = new_shares_amount, id = share_holder["id"])
return render_template("buy.html")
это проблемный раздел, в котором появляется ошибка, в строке 4:
# if user have at least one share already
else:
new_shares_amount = int(share_holder["amount"]) shares
db.execute("UPDATE stocks SET amount = :amount WHERE id = :id", amount = new_shares_amount, id = share_holder["id"])
return render_template("buy.html")
заранее спасибо