为了账号安全,请及时绑定邮箱和手机立即绑定

(1064,“您的SQL语法有错误; ..在第1行使用正确的语法以在'%s,%s,%s,%s,%s)

(1064,“您的SQL语法有错误; ..在第1行使用正确的语法以在'%s,%s,%s,%s,%s)

慕的地6264312 2021-06-01 15:17:24
我正在尝试将数据插入到我的 mysql 数据库中,但我总是得到一个错误,即参数有问题,我想将其添加到我的插入语句中,我尝试了各种解决方案以及带有 ' s','s'工作正常,它已插入我的数据库中。有没有人知道什么是错的?谢谢。try:    conn = mysql.connect()    cursor = conn.cursor()    insert_cmd = "INSERT INTO TBTAB VALUES(%s, %s, %s, %s, %s)"    #insert_cmd = "INSERT INTO TBTAB VALUES('s', 's', 's', 's', 's')"    # insert_cmd = "INSERT INTO TBTAB VALUES(?, ?, ?, ?, ?)"    tpa= ("szilva", "barack", "meggye", "alma", "korte")    #cursor.execute("INSERT INTO TBTAB (UserName, Email, TextBoxCont, NodeChosen, CurDate) VALUES ('Caal', 'TomErichsen', 'Svanger', '400esd6', 'Nqdwasorway');")    cursor.execute(insert_cmd.format(tpa))    conn.commit()    return render_template('form.html')except Exception as e:    return str(e)错误:(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, %s, %s, %s, %s)' at line 1")
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 205 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号