Flask-Mysql Python 将 table 更新为 Mysql 时出现 1064 错误
Flask-Mysql Python 1064 error when update table into Mysql
在使用 Flask python.
构建 Web 应用程序时,由于此更新 mysql table 错误而被困了一整天
(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")
根据 Whosebug 中类似问题的解决方案,尝试删除逗号并添加 ``,但它不起作用。
@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)
从 sql 变量中删除逗号:
sql = "UPDATE user SET user_photo=%s WHERE user_id=%s"
在使用 Flask python.
构建 Web 应用程序时,由于此更新 mysql table 错误而被困了一整天(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")
根据 Whosebug 中类似问题的解决方案,尝试删除逗号并添加 ``,但它不起作用。
@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)
从 sql 变量中删除逗号:
sql = "UPDATE user SET user_photo=%s WHERE user_id=%s"