Re: Connection function

From: Bill House <wch-tech(at)house-grp(dot)net>
To: psycopg(at)postgresql(dot)org
Subject: Re: Connection function
Date: 2012-03-28 11:30:28
Message-ID: 4F72F654.1000100@house-grp.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg


Thanks for all the help from everyone; I have a lot of studying to do.

Regards

Bill

On 03/26/2012 02:52 AM, Federico Di Gregorio wrote:
> On 25/03/12 17:14, Bill House wrote:
> [snip]
>> Sometimes it is helpful to know how many records one is working with.
>>
>> From my reading in the psycopg2 documentation (2.4.4) and
>> experimentation, I think that this information is only available if one
>> uses an unnamed cursor (in which case all the data will have been
>> fetched to the client) or with an named cursor (but only after all the
>> data has been fetched).
>>
>> If there is a large amount of data, this may be problematic.
>
> Not at all. You just need to MOVE to the end of the result set and
> count how many rows you skipped. At the moment psycopg doesn't use
> MOVE return value (that tells you what you want to know) but can just
> .execute() the MOVE and access the result on the cursor. Also, we
> could probably extend scroll() to return the number of scrolled rows
> in the future.
>
>> In particular, I am interested in:
>> 1) the python string substitution technique I used
>
> Use bound parameters:
>
> http://packages.python.org/psycopg2/usage.html#query-parameters
>
> federico
>

In response to

Browse psycopg by date

  From Date Subject
Next Message Federico Di Gregorio 2012-03-28 21:30:23 RELEASE: psycopg 2.4.5
Previous Message Federico Di Gregorio 2012-03-26 07:52:02 Re: Connection function