From:
[email protected]
Package: python2.3-psycopg
Version: 1.1.15-1
Installed version of postgresql is 7.4.3-3
psycopg appears to always returns 0 for curs.rowcount after an INSERT
or UPDATE. There's nothing in the README to explain why.
dbapi 2.0 says:
.rowcount
This read-only attribute specifies the number of rows that
the last executeXXX() produced (for DQL statements like
'select') or affected (for DML statements like 'update' or
'insert').
The attribute is -1 in case no executeXXX() has been
performed on the cursor or the rowcount of the last
operation is not determinable by the interface.
Test script:
DSN = 'dbname=test user=test'
import sys, psycopg
if len(sys.argv) > 1:
DSN = sys.argv[1]
conn = psycopg.connect(DSN)
curs = conn.cursor()
curs.execute("""
CREATE TABLE test_table (id INTEGER)
""")
curs.execute("INSERT INTO test_table VALUES (%s)", (1,))
if curs.rowcount != 1:
print "INSERT: saw rowcount %d, should be 1" % curs.rowcount curs.execute("UPDATE test_table SET id=%s", (2,))
if curs.rowcount != 1:
print "UPDATE: saw rowcount %d, should be 1" % curs.rowcount
curs.close()
--
To UNSUBSCRIBE, email to
[email protected]
with a subject of "unsubscribe". Trouble? Contact
[email protected]
--- SoupGate-Win32 v1.05
* Origin: you cannot sedate... all the things you hate (1:229/2)