[Tutor] how best to implement paginated data in CLI

Alan Gauld alan.gauld at btinternet.com
Wed Sep 15 02:15:53 CEST 2010


"Rance Hall" <ranceh at gmail.com> wrote

> I'm using python 3.1 with py-postgresql (located at
> http://python.projects.postgresql.org/
>
> I need to work through how best to paginate larger sql result sets.

Its usually best to do that at the SQL level by controlling the 
cursor.
I don't know PostGres but most SQL dialects allow you to control
the number of result rows returned to the cursor then fetch the next
group and the next etc. This will also potentially save a lot of 
network
bandwidth (you only fetch the results you need which may not be
all of them) and get your results back quicker for a big result set.

HTH,


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




More information about the Tutor mailing list