sqlite没有返回第二个cursor.fetchall()后
问题描述:
为什么我什么时候在cursor.execute()之后两次执行cursor.fetchall()?无论如何阻止这种情况发生?我是否需要将信息存储在变量中?它是否以这种方式工作?sqlite没有返回第二个cursor.fetchall()后
答
fetchall
做它说的 - 它提取所有。那之后什么都没有了。要获得更多结果,您需要运行另一个查询(或再次查询同一个查询)。
从Python db-api 2.0 specification:
cursor.fetchall() Fetch all (remaining) rows of a query result, returning them as a sequence of sequences (e.g. a list of tuples). Note that the cursor's arraysize attribute can affect the performance of this operation. cursor.fetchone() Fetch the next row of a query result set, returning a single sequence, or None when no more data is available. [6]
不过,什么是 “一”?检索到的查询的一项? – relima 2010-11-11 02:47:34
@relima:“检索到的查询中的一项?”它还能是什么? – 2010-11-11 02:52:40
@relima:从文档中添加引用 – 2010-11-11 02:53:36