这很好用:
cc.execute("select * from books where name like '%oo%'")
但如果传入第二个参数:
cursor.execute("select * from books where name like '%oo%' OFFSET % LIMIT %", (0,1))
Psycopg错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IndexError: tuple index out of range
如何避免这个错误?
cursor.execute("select * from books where name like '%%oo%%' OFFSET %s LIMIT %s", (0,1,))
,否则会出现“TypeError: not all arguments converted during string formatting”错误。 - Nicholas Morley