2012/1/16 Jacek Kałucki <laborm(at)rz(dot)onet(dot)pl>:
> 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.
In response to
psycopg by date
|Next:||From: Jacek Kałucki||Date: 2012-01-16 13:53:37|
|Subject: Re: Fetching query result problem|
|Previous:||From: Jacek Kałucki||Date: 2012-01-16 12:53:20|
|Subject: Fetching query result problem|