Hi I have been working on a flask web app, It has many tables with relation among themselves. One table is users_email.
+---------+------------------+
| user_id | email |
+---------+------------------+
| 6 | akki@gmail.com |
| 9 | nskans@gmail.com |
+---------+------------------+
I am trying to insert a row from a flask route @app.route('/get_email')
@app.route('/get_email', methods=['GET', 'POST'])
def get_email():
form=EmailRegistrationForm()
if form.validate_on_submit():
email = form.email.data
app.logger.info(email)
app.logger.info(session['user_id'])
cur = mysql.connection.cursor()
cur.execute("INSERT INTO users_email(user_id, email) VALUES(%s, %s)",(session['user_id'], email))
app.logger.info('query executed sucessfully!!! check the table if it did or not!')
cur.close()
flash('Registered email sucessfully!', 'success')
return redirect(url_for('admin_options'))
return render_template('get_email.html', title='Register your email', form=form)
when I directed to this route, it executed perfectly with out any error and after completing this, as this route should do it get redirected to 'admin_option'. if I see back in the data base there are no new row gets entered
Aucun commentaire:
Enregistrer un commentaire