Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cursor.rowcount does not reset when executing the same statement a second time #193

Closed
dsarratt opened this issue Jun 25, 2018 · 3 comments
Labels

Comments

@dsarratt
Copy link

The cursor.rowcount attribute seems to increment when running the same query multiple times, when I expected it to reset. Example:

cur = mycon.cursor()
STMT = "SELECT * FROM DUAL WHERE 1=:s"

cur.execute(STMT, [0])
_ = cur.fetchone()
print cur.rowcount

cur.execute(STMT, [1])
_ = cur.fetchone()
print cur.rowcount

cur.execute(STMT, [1])
_ = cur.fetchone()
print cur.rowcount

cur.execute(STMT, [0])
_ = cur.fetchone()
print cur.rowcount

Expected output:

0
1
1
0

Actual output:

0
1
2
2

Documentation

PEP 249 suggests the rowcount should reset to zero every time execute() is called:
https://www.python.org/dev/peps/pep-0249/#rowcount

Answer the following questions:

  1. What is your version of Python? Is it 32-bit or 64-bit?
    Python 2.6.6, 64-bit
    Same behaviour observed on Python 2.7.12, 64-bit

  2. What is your version of cx_Oracle?
    6.3

  3. What is your version of the Oracle client (e.g. Instant Client)? How was it
    installed? Where is it installed?
    Installed via pip, /usr/lib64/python2.6/site-packages/cx_Oracle.so

  4. What is your version of the Oracle Database?
    12.1c

  5. What is your OS and version?
    RHEL6

@anthony-tuininga
Copy link
Member

You are correct. The row count is not being reset for each execute and it should be. I'll have that corrected.

@anthony-tuininga
Copy link
Member

This issue has been corrected and a test case added to the test suite to ensure it doesn't happen again. Thanks for bringing it to my attention!

@dsarratt
Copy link
Author

Wow, that's a fast turnaround! Thanks for all the hard work. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants