python - mysql.connector.errors.ProgrammingError : Error in SQL Syntax

标签 python mysql

我正在使用 Python MySQL 连接器通过更新行来将数据添加到表中。用户输入序列号,然后添加包含序列号的行。我不断收到 SQL 语法错误,但无法弄清楚它是什么。

  query = ("UPDATE `items` SET salesInfo = %s, shippingDate = %s, warrantyExpiration = %s, item = %s, WHERE serialNum = %s")
        cursor.execute(query, (info, shipDate, warranty, name, sn, ))
        conn.commit()

错误:

mysql.connector.errors.ProgrammingError: 1064 (42000): 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 serialNum = '1B0000021A974726'' at line 1

“1B0000021A974726”是用户输入的序列号,它已经存在于表中。

最佳答案

WHERE 语句之前没有 ,

关于python - mysql.connector.errors.ProgrammingError : Error in SQL Syntax,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54699959/

相关文章:

python - 如何使用带有 stdin 的 wall 命令将消息广播到 python 中的所有 bash 终端?

python - [pandas.read_csv(filename)] 和 [pandas.DataFrame.from_csv(filename)] 有什么区别

python - Beautifulsoup 的输出

php - 对数据库中所有表的字段求和

mysql - MYSQL 中的自定义更新时间

mysql - 使用表别名的 SQL 查询

python - 如何使用子流程模块正确地与流程交互

python - 为什么 python 包在 python 3.5 中显示为模块?

php - 在 php 和 mysql 中使用 IP

mysql - 如何在数据库中存储已付款和未付款的订单?