0

我在 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.
>>> 

我已经阅读了很多关于此的其他帖子,但我仍然不确定该怎么做。尝试不同

4

1 回答 1

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]))
于 2013-05-16T21:31:35.653 回答