Mysql
 sql >> Datenbank >  >> RDS >> Mysql

Abrufen der Eingabe aus dem HTML-Formular und Speichern in mysql über Flask

@app.route('/',methods=['GET','POST'])
def get_data():
  if request.method=='POST':
    first_name=request.form['fname']
    last_name=request.form['lname']
    emailid=request.form['emailid']
    connection = mysql.get_db()
    cursor = connection.cursor()
    query="INSERT INTO names_tbl(f_name,l_name,e_id) VALUES(%s,%s,%s)"
    cursor.execute(query,(first_name,last_name,email_id))
    connection.commit()

 return render_template("sample.html")

if __name__=='__main__':
app.run(debug=True)