Python SQLite';绑定参数0时出错:可能是不支持的类型';什么意思?
我有Python代码:Python SQLite';绑定参数0时出错:可能是不支持的类型';什么意思?,python,sqlite,python-db-api,Python,Sqlite,Python Db Api,我有Python代码: cursor.execute('INSERT INTO users (email, password, password_hint, state, last_saved) VALUES (?, ?, ?, ?, DATETIME("now"));', ((get_cgi('email'),), (password,), (get_cgi('password_hint'),), (get_cgi('current'),))) 这将生成以下错误: Traceback (mo
cursor.execute('INSERT INTO users (email, password, password_hint, state, last_saved) VALUES (?, ?, ?, ?, DATETIME("now"));',
((get_cgi('email'),), (password,), (get_cgi('password_hint'),), (get_cgi('current'),)))
这将生成以下错误:
Traceback (most recent call last):
File "./create_account.cgi", line 73, in <module>
((get_cgi('email'),), (password,), (get_cgi('password_hint'),), (get_cgi('current'),)))
sqlite3.InterfaceError: Error binding parameter 0 - probably unsupported type.
回溯(最近一次呼叫最后一次):
文件“/create_account.cgi”,第73行,在
((获取cgi(“电子邮件”),(密码),(获取cgi(“密码提示”),,(获取cgi(“当前”),))
sqlite3.InterfaceError:绑定参数0时出错-可能是不支持的类型。
在崩溃之前放置的get_cgi(“email”)调试日志返回预期的电子邮件地址,因此我希望TEXT类型的“email”列能够处理它
SQLite3在抱怨什么?我是否错过了DB-API2的一些细节?我不知道为什么要创建所有这些嵌套元组,但是删除它们应该会让事情变得更好;不支持将元组插入(至少以这种方式)文本字段
cursor.execute(
'INSERT INTO users (email, password, password_hint, state, last_saved) ' +
'VALUES (?, ?, ?, ?, DATETIME("now"));',
(get_cgi('email'), password, get_cgi('password_hint'), get_cgi('current')))
我不知道为什么要创建所有这些嵌套的元组,但是删除它们应该会让事情变得更好;不支持将元组插入(至少以这种方式)文本字段
cursor.execute(
'INSERT INTO users (email, password, password_hint, state, last_saved) ' +
'VALUES (?, ?, ?, ?, DATETIME("now"));',
(get_cgi('email'), password, get_cgi('password_hint'), get_cgi('current')))
非常感谢。它正在工作。我还以为其他DB-API2文档会给出元组,而不是非容器类型或字符串。@JonathanHayward所有参数都应该在同一个元组中,这就是为什么
()
将所有参数都放在一起的原因。谢谢;它正在工作。我还以为其他DB-API2文档会给出元组,而不是非容器类型或字符串。@JonathanHayward所有参数都应该在同一个元组中,这就是为什么()
将所有参数都放在一起的原因。