使用我的应用程序并尝试更改密码时,出现此错误,我不知道如何解决
@app.route("/changes", methods= ['GET','POST'])
def change():
user = "Login"
change_form = forms.ChangeForm(request.form)
if 'username' in session:
username = session["username"]
get = db.execute("SELECT * FROM users WHERE cedula = :e", {"e": username}).fetchone()
user = get.nombre
actual = get.password
print (actual)
if request.method == 'POST' and change_form.validate():
password = change_form.password.data
new_password = change_form.new_password.data
confirm_password = change_form.confirm_password.data
if password == actual:
cambio = db.execute("UPDATE users SET password = :new_password WHERE password = :password",{"new_password": confirm_password, "password":actual}).fetchone()
success_message = 'Cambio Exitoso.'
flash(success_message)
else:
error_message = 'No se pudo cambiar la contraseña.'
flash(error_message)
#success_message = '{} Has cambiado tu contraseña!'.format(user)
#flash(success_message)
db.commit()
return render_template('changes.html',form = change_form, user=user)
应该正常运行,但出现此错误:
此结果对象不返回行。它已自动关闭。
答案 0 :(得分:0)
cambio = db.execute(“更新用户设置密码=:new_password,其中密码=:password”,{“ new_password”:Confirm_password,“ password”:actual}) .fetchone() 这是我的错误大声笑