我在编辑从DB获取的值时遇到了问题。 遇到以下错误:
mysql_exceptions.ProgrammingError: (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 '%s' at line 1")
结果显示如下
例如,当单击“编辑配置文件”时,将正确获取以下详细信息
在编辑详细信息并单击提交时遇到上述错误
使用下面的代码编辑结果
@app.route('/Update', methods=['GET', 'POST'])
def Update():
CR_ID = request.args.get('CR_ID')
cur = mysql.connection.cursor()
result = cur.execute("""SELECT CR_ID, name, email, CRType from users where CR_ID = %s""",CR_ID)
# result = cur.execute("Update table users set name=?, email=?, CRType=? where CR_ID = %s", CR_ID)
RV = cur.fetchall()
user = RV[0]
cur.close()
return render_template('Update.html',user=user)
使用以下代码更新记录:
@app.route('/UpdateData', methods=['GET', 'POST'])
def UpdateData():
name = request.args.get('name')
email = request.args.get('email')
CRType = request.args.get('CRType')
cur = mysql.connection.cursor()
result = cur.execute("""Update table users set name=?, email=?, CRType=? where CR_ID = ?""")
mysql.connection.commit()
cur.close()
return index()
目前没有回答
相关问题 更多 >
编程相关推荐