cursor.rowcount does not reset when executing the same statement a second time · Issue #193 · oracle/python-cx_Oracle · GitHub
Skip to content

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

Description

@dsarratt

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions