Flask Post Data To Table Using Sqlalchemy/mysql
I am trying to write data to a MySQL table from a html form, using Flask/Python/SQLAlchemy on Pythonanywhere. Mysql table is setup, I can enter data on the /transactions, but then
Solution 1:
You can call Model by tablename .
you code should like this .. instead of transactions1
@app.route('/transactions', methods=['GET', 'POST'])
def transactions():
if request.method == 'GET':
return render_template('Transactions.html')
sale = Transactions1(Item=request.form["Item"],Shack=request.form["Shack"],Paym_Reference=request.form["Paym_Reference"],Amount=request.form["Amount"])
db.session.add(sale)
db.session.commit()
return render_template('Transactions.html')
Post a Comment for "Flask Post Data To Table Using Sqlalchemy/mysql"