#!/usr/bin/python
import sqlite3
conn = sqlite3.connect("/home/michael/Dropbox/lagniappe/database.db")
cursor = conn.cursor()
query = raw_input('Search for a title:')
cursor.execute("SELECT * FROM nerd WHERE title LIKE '%?%';", query)
print cursor.fetchall()
返回错误:
michael@piplup:~$ python sqlite.py
Search for a title:test
Traceback (most recent call last):
File "sqlite.py", line 10, in <module>
cursor.execute("SELECT * FROM nerd WHERE title LIKE '%?%';", query)
sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 0, and there are 4 supplied.
我想要它做的就是将它从数据库接收到的数据打印到控制台。最终我想操作这些数据,但我只需要查询正常工作。