这是我的代码:
def delWorker():
deleteWorker = input('Please type in the surname of the worker you would like to delete. ')
c.execute("DELETE FROM employees WHERE lastName = (?)",
(deleteWorker))
conn.commit()
我收到'incorrect bindings supplied error'
的错误消息
答案 0 :(得分:2)
您想要
c.execute("DELETE FROM employees WHERE lastName = (?)", (deleteWorker,))
=>注意deleteWorker
之后的逗号,这就是创建tuple
的原因-括号仅用于消除歧义,因此没有逗号,Python看到的是:
c.execute("DELETE FROM employees WHERE lastName = (?)", deleteWorker)
因此,当cursor.execute()
期望使用tuple
或list
时,您实际上是在传递字符串。