我在python中的sqlite3语句中遇到绑定问题。任何帮助都会被贬低。感谢
print page
print section
cur.execute('SELECT * FROM docList WHERE pageFileName = ? AND sectionTitle = ?',(page,section,))
这是输出
(u'current_reports.html',)
(u'Intro',)
Traceback (most recent call last):
File "C:\Work\Dropbox\Public\www\propagateIndex.py", line 65, in <module>
cur.execute('SELECT * FROM docList WHERE pageFileName = ? AND sectionTitle = ?',(page,section,))
InterfaceError: Error binding parameter 0 - probably unsupported type.
>>>
我已经阅读了很多关于此的帖子,但我不知道该怎么做。试过不同的
答案 0 :(得分:1)
page
和section
是元组;你想只插入第一个元素。最简单的是连接这些:
cur.execute('SELECT * FROM docList WHERE pageFileName = ? AND sectionTitle = ?',
page + section)
或使用索引:
cur.execute('SELECT * FROM docList WHERE pageFileName = ? AND sectionTitle = ?',
(page[0], section[0]))