Re: Fetching query result problem

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
To: Jacek Kałucki <laborm(at)rz(dot)onet(dot)pl>
Cc: psycopg(at)postgresql(dot)org
Subject: Re: Fetching query result problem
Date: 2012-01-16 13:18:30
Message-ID: CA+mi_8aUEV7yVXr05V9iTtAEYuWzHtnZ7RScgQwB_fn6cNUc3w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

2012/1/16 Jacek Kałucki <laborm(at)rz(dot)onet(dot)pl>:
> Hi.
>
> I have a problem with some query.
> When I issue it from within postgresql console, it returns correct rows
> count as a result,
> but when executed within psycopg2 cursor.execute() row count differs.
> In first situation I get 5 rows versus 3 at second time.
[...]
> Could you give me any suggestions how to figure the reason out?

There's no reason why this should happen.

- It could be a different in transactions usage: a query run in psql
is not wrapped in a transaction whereas psycopg has an implicit
"begin" before, and data is not committed until you explicitly commit:
make sure the data you are expecting is visible. Try running the query
in psycopg with autocommit = true to get the same data visibility you
have in psql.

- could you have python data types converted to something unexpected?
Enable server logging to see the query the backend receives, and use
diff to compare the logs and spot differences between what received
from psql and what from psycopg.

- check the connection string: you may be talking to the wrong database.

-- Daniele

In response to

Responses

Browse psycopg by date

  From Date Subject
Next Message Jacek Kałucki 2012-01-16 13:53:37 Re: Fetching query result problem
Previous Message Jacek Kałucki 2012-01-16 12:53:20 Fetching query result problem