Been stuck whole day with this update mysql table error while build a web app with Flask python.
(1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE 'user_id'='28'' at line 1")
Tried removing comma and adding `` according to solution of similar problems in Stackoverflow but it's not working.
@app.route('/update')
def update():
try:
conn = mysql.connect()
update = conn.cursor(pymysql.cursors.DictCursor)
sql = "UPDATE user SET user_photo=%s, WHERE user_id=%s"
_path="User.30.1.jpg"
_id="28"
data = (_path,_id)
update.execute(sql,data)
conn.commit()
return render_template('training.html')
except Exception as e:
print(e)
Remove the comma from the sql variable:
sql = "UPDATE user SET user_photo=%s WHERE user_id=%s"