Issue
I'm making a function in my e-commerce website which updates credentials of a user. whenever my form triggers this function I get the error -> sqlalchemy.exc.DataError: (psycopg2.errors.InvalidTextRepresentation) invalid input syntax for type boolean: "sdzf"
I'm unable to find out what's wrong. Please help me find the issue. Thanks in advance.
python code:
@app.route("/admin_cred_update", methods=["POST","GET"])
def admin_cred_update():
email=str(request.form.get("email"))
password=str(request.form.get("password"))
if re.search("[.,*/%$#:|\[\]\(\)]",email) and re.search("[.,*/%$#:|\[\]\(\)]",password):
message="there are some invalid characters in above fields"
return render_template("admin_profile.html", updatemes=message)
else:
db.execute("update admin_master_tbl SET email=:email and password=:password where email=:smail and password=:spassword",{"email":email,"password":password,"smail":session["adminname"],"spassword":session["adminpassword"]})
session["adminname"]=email
session["adminpassword"]=password
message1="credentials updated succesfully"
return render_template("admin_profile.html", updatemes=message1)
error log:
sqlalchemy.exc.DataError: (psycopg2.errors.InvalidTextRepresentation) invalid input syntax for type boolean: "sdzf"
LINE 1: update admin_master_tbl SET email='sdzf' and password='csadf...
^
[SQL: update admin_master_tbl SET email=%(email)s and password=%(password)s where email=%(smail)s and password=%(spassword)s]
[parameters: {'email': 'sdzf', 'password': 'csadfc', 'smail': '[email protected]', 'spassword': 'asdf'}]
Solution
Oh I found the problem!!. I did the mistake of putting and
instead of ,
in the SET
part of my query. Now the problem is solved!!.
Answered By - stormcloak
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.