large return resuls

From: maplabs(at)light42(dot)com
To: psycopg(at)postgresql(dot)org
Cc: nick(at)calthorpe(dot)com
Subject: large return resuls
Date: 2012-01-10 22:28:34
Message-ID: 20120110142834.113b30useocgss4c@webmail.light42.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

Hi All-

  I am just returning to a psycopg2 project after a break..
We are using 2.4.2  on Linux, python 2.7, postgres 9.1

 If I make a query that returns truly large results
that is, both a lot of data per record, and a lot of records
What is the best way to handle that ?

Right now I just declare a cursor, execute() and then

for rec in cursor.fetchall():
  .... stuff ..

on the hardware it is on, it is working fine apparently..
but it got me wondering..

fetchone()  fetchmany(..) and fetchall()
  will all basically pull the data at once, yes?

a server side cursor is the only way to bring data piece by piece, yes?

  thanks
   -Brian

Responses

Browse psycopg by date

  From Date Subject
Next Message Daniele Varrazzo 2012-01-11 00:27:06 Re: large return resuls
Previous Message Daniele Varrazzo 2012-01-10 21:57:44 Re: Use lo_creat() when possible instead of lo_create()