我正在嘗試將數(shù)據(jù)插入到我的 mysql 數(shù)據(jù)庫中,但我總是得到一個(gè)錯(cuò)誤,即參數(shù)有問題,我想將其添加到我的插入語句中,我嘗試了各種解決方案以及帶有 ' s','s'工作正常,它已插入我的數(shù)據(jù)庫中。有沒有人知道什么是錯(cuò)的?謝謝。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)錯(cuò)誤:(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")
(1064,“您的SQL語法有錯(cuò)誤; ..在第1行使用正確的語法以在'%s,%s,%s,%s,%s)
慕的地6264312
2021-06-01 15:17:24