From: <Sha...@su...> - 2003-05-29 08:29:26
|
I believe the current behavior is correct according to the DB API spec, because when a query is executed, but no fetch has been performed, the interface cannot determine the number of rows produced (second clause, not first). 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.[7] Peter's problems with his patch indicate that the Sybase module decides on its own when exactly to perform fetches (until the time they are actually needed, of course). In this case, the consistent behavior of returning -1 until the user actually tries to fetch something sounds preferable. To the best of my knowledge, Sybase libraries do not reliably report an empty query until you actually try to fetch something, so the problem is not with the Python module. Peter: If you absolutely need to know the number of rows before you try to fetch anything, you can select count(*) with the same tables and conditions, before your query. This will always return one row... In theory, it could be done in the same query (using the Sybase "compute" clause, returning a separate result set),=20 but IIRC the compute results are returned only after the "regular" results, so you could only get to the rowcount this way by first discarding all the rows. Hope this helps, Shai. |