Re: cursor.rowcount not functioning as expected

"Amaury Forgeot d'Arc" <[email protected]> Tue, 3 Nov 2015 18:01:19 +0100
Newsgroups gmane.comp.python.db.cx-oracle
Message-ID <CAGmFidb5mvb-psGwy2u+ATUYRtWVPN0-X_7gwNh0A+Wp4R6QNg@mail.gmail.com>
Hi,

2015-11-03 17:43 GMT+01:00 <[email protected]>:

>
> I haven't seen any messages on this list for several days.
> I'm not sure if things are just quiet or I am having issues with the list
> server.
>

No, it's just a quiet list. But your question is perfectly on-topic.


> My apologies if this is duplicate - I never saw any response, so I am
> sending it again.
> (If this message was already received and there have been responses then I
> am indeed
> having mail list issues and I am not sure how to resolve that - please
> copy any other
> responses directly to me.)
>
> I am starting to use cx_Oracle and happy to have it so, thanks Anthony for
> sharing your work.
>
> Maybe I am not understanding something about the documentation of
> cursor.rowcount
> The documentation at:
>
>     https://www.python.org/dev/peps/pep-0249/#cursor-attributes    says:
>
> .rowcount
> This read-only attribute specifies the number of rows that the last
> .execute*() produced (for DQL statements like SELECT ) or affected (for DML
> statements like UPDATE or INSERT ).
>

On the other hand, cxOracle docs say:
"This read-only attribute specifies the number of rows that have currently
been fetched from the cursor (for select statements)..."
http://cx-oracle.readthedocs.org/en/latest/cursor.html#Cursor.rowcount

This is how Oracle works, there is no way to retrieve the number of rows
upfront,
unless you run a "select count(*)" query.


>
> I have a cursor variable in the interpreter as 'cur':
>
> >>> cur.execute('select * from isotope')
> <__builtin__.OracleCursor on <cx_Oracle.Connection to some_user@some_sid>>
> >>> cur.rowcount
> 0
> >>> recs = cur.fetchall()
> >>> recs[0]
> ('Co-55', 'Cobalt 55', None, None)
> >>> len(recs)
> 389
> >>> cur.rowcount
> 389
>
> I think cur.rowcount should return 389 in the first call above.
> Is that not the right interpretation?
>
> Thanks,
> Erik Johnson
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> cx-oracle-users mailing list
> cx-oracle-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/cx-oracle-users
>



-- 
Amaury Forgeot d'Arc

------------------------------------------------------------------------------

_______________________________________________
cx-oracle-users mailing list
cx-oracle-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/cx-oracle-users