python cx_oracle cursor.rowcount returning 0 but cursor.fetchall returns data python cx_oracle cursor.rowcount returning 0 but cursor.fetchall returns data database database

python cx_oracle cursor.rowcount returning 0 but cursor.fetchall returns data


The documentation states that cursor.rowcount specifies the number of rows that have currently been fetched. Immediately after the cursor.execute() call has been made, no rows have been fetched, so the result is 0. If you call cursor.fetchone() then result will be 1 and if you call cursor.fetchmany(5), then the result will be 6, and so forth (assuming there are enough rows to satisfy your requests, of course!).


cx-oracle.readthedocs mentioned Cursor.rowcount specified number of rows affected by insert, update and delete statement. You are using a select statement.

cur.execute('select * from table1')result = cur.fetchall()print (len(result)) # this will return number of records affected by select statementprint (result)