使用Python更新SQL-绑定数量不正确

使用Python更新SQL-绑定数量不正确,python,sqlite,Python,Sqlite,我一直在犯这个错误 Traceback (most recent call last): File "test.py", line 7, in <module> c.execute("INSERT INTO file_routes (file_route) VALUES (?)", (file_route)) sqlite3.ProgrammingError: Incorrect number of bindings supplie

我一直在犯这个错误

Traceback (most recent call last):
  File "test.py", line 7, in <module>
    c.execute("INSERT INTO file_routes (file_route) VALUES (?)", (file_route))
sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 1, and there are 4 supplied.

这是我试图运行的代码,但它不起作用

import sqlite3

conn = sqlite3.connect('fantasyresults.db')
c = conn.cursor()

file_route = "test"

c.execute("INSERT INTO file_routes (file_route) VALUES (?)", (file_route))
conn.commit()
我不明白为什么这段代码可以工作,我用同样的方法设置了结构。
c.execute
大于
(“插入()值(?),())


非常感谢您的帮助,我不知道我在这里没有看到什么。

问题是,它将参数视为
string
,而不是
tuple
,因为这是python中对于具有单个元素的tuple的预期行为

尝试将参数元组更新为

(file_route, )

在参数后面加一个逗号。

问题在于,它将参数视为
字符串而不是
元组,因为这是python中对于具有单个元素的元组的预期行为

尝试将参数元组更新为

(file_route, )

在参数后面有一个逗号

O M G我爱你哈哈,哇,我花了大约2个小时在python的SQLite文档上lol,当你刚刚写下逗号时我笑得很厉害你回答得这么快,必须等待才能标记为答案>。O M G我爱你哈哈,哇,我花了大约2个小时在python的SQLite文档上,哈哈,当你刚刚写下命令的时候,我笑得很厉害。你回答得太快了,在你可以标记为answer>之前必须等待。
(file_route, )