When I enter amount, name, expinc in my html form it works for the first time, i.e. the entered data goes into database tables for the first time but whenever I try to enter data again it doesn't show up in tables. It looks like db.execute function executing not more than one time.
@app.route("/buy", methods=["GET", "POST"])
@login_required
def buy():
if request.method == "GET":
return render_template("buy.html")
else:
amounts = int(request.form["amount"])
names = request.form["name"]
expincs = request.form["expinc"]
db.execute("INSERT INTO histories (id, amount, name, expinc) \
VALUES(:id, :amount, :name, :expinc)", \
id=session["user_id"], amount=usd(amounts),\
name=names, expinc=expincs)
db.execute("INSERT INTO portfolio (id, amount, name, expinc) \
VALUES(:id, :amount, :name, :expinc)", \
id=session["user_id"], amount=usd(amounts), \
name=names, expinc=expincs)
return redirect(url_for("index"))