Navigating cursor rows in SQLite
Posted
by Alan Harris-Reid
on Stack Overflow
See other posts from Stack Overflow
or by Alan Harris-Reid
Published on 2010-05-09T03:35:48Z
Indexed on
2010/05/09
3:48 UTC
Read the original article
Hit count: 324
Hi there,
I am trying to understand how the following builtin functions work when sequentially processing cursor rows. The descriptions come from the Python 3.1 manual (using SQLite3)
Cursor.fetchone() Fetches the next row of a query result set, returning a single sequence.
Cursor.fetchmany() Fetches the next set of rows of a query result, returning a list.
Cursor.fetchall() Fetches all (remaining) rows of a query result, returning a list.
So if I have a loop in which I am processing one row at a time using cursor.fetchone(), and some later code requires that I return to the first row, or fetch all rows using fetchall(), how do I do it?
The concept is a bit strange to me, especially coming from a Foxpro background which has the concept of a record pointer which can be moved to the 1st or last row in a cursor (go top/bottom), or go to the nth row (go n)
Any help would be appreciated.
Alan
© Stack Overflow or respective owner