[python-sybase] cursor.rowcount broken?

Andrew McNamara andrewm at object-craft.com.au
Fri, 30 Jul 2004 00:11:36 +1000


>I'm using version 0.36 of the Sybase module, linked against Sybase OCS
>libraries.
>I want to use the cursor.rowcount value, but it always seems to return -1, did I
>understand something wrong?
>
> >>> db = Sybase.connect("XXX", "XXX", "XXX")
> >>> c = db.cursor()
> >>> c.execute("select * from pers")
> >>> print c.rowcount
> -1
> >>> print len(c.fetchall())
> 7

I can't speak for the Sybase module, but pyPgSQL (a python postgres
connector) only initialises this variable after you've fetched your rows.
In their case, it appears to be a limitation of the Postgres C API,
rather than a problem with the python adaptor: I think the database is
reserving the right to return partial results while still performing
the query (so even it doesn't know how many rows will be returned).

-- 
Andrew McNamara, Senior Developer, Object Craft
http://www.object-craft.com.au/