【发布时间】:2019-08-24 19:42:41
【问题描述】:
产生此错误的代码有什么问题
mysql.connector.errors.ProgrammingError: 1064 (42000): You have an error in
your SQL syntax; check the manual that corresponds to your MariaDB server
version for the right syntax to use near '%s)' at line 1
我在 Python 中使用 XAMPP 本地主机数据库和 mysql.connector 包。我的插入代码:
cursor = db.cursor()
username = input()
sql = "INSERT INTO `employee` (`id`, `username`) VALUES (NULL, %s)"
cursor.execute(sql, username)
db.commit()
print("success")
【问题讨论】:
标签: python-3.6