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
nzxdsarratt opened this Issue Jun 25, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@nzxdsarratt
Copy link

nzxdsarratt commented Jun 25, 2018

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

This comment has been minimized.

Copy link
Member

anthony-tuininga commented Jun 25, 2018

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

@anthony-tuininga

This comment has been minimized.

Copy link
Member

anthony-tuininga commented Jun 25, 2018

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!

@nzxdsarratt

This comment has been minimized.

Copy link
Author

nzxdsarratt commented Jun 25, 2018

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