-
Notifications
You must be signed in to change notification settings - Fork 358
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 under Python 3.7.2 #281
Comments
I just ran the original test case with cx_Oracle 7.1.2 on Python 3.7.2 and I didn't see any issues. Can you provide a test case that demonstrates the problem? |
Sorry for the late answer. Sample code: for file in os.listdir('.'):
if fnmatch.fnmatch(file, '*x1.csv'):
with open (file, 'r') as f:
reader = csv.reader(f)
next(reader)
FLEXPARAList= list (reader)
try:
cursor.executemany("""insert into test1 (col1, col2, col3)
values (:1, :2, :3)""",FLEXPARAList)
except cx_Oracle.DatabaseError as err:
errorObj, = err.args
logger.info ("The error is: '%s' in the test1 table", errorObj.message)
size = len(errorObj.message)
if size > 0 :
error_number = error_number + 1
logger.info ("'%s' row inserted in the test1 table", cursor.rowcount)
// X2 csv
for file in os.listdir('.'):
if fnmatch.fnmatch(file, '*x2.csv'):
with open (file, 'r') as f:
reader = csv.reader(f)
next(reader)
LAPARAMList= list (reader)
try:
cursor.executemany("""insert into test2 (col1,col2, col3, col4)
values (:1, :2, :3, :4)""",LAPARAMList)
except cx_Oracle.DatabaseError as err:
errorObj, = err.args
logger.info ("The error is: '%s' in the test2 table", errorObj.message)
size = len(errorObj.message)
if size > 0 :
error_number = error_number + 1
logger.info ("'%s' row inserted in the test2 table", cursor.rowcount) |
That would be expected. If you call cursor.executemany() with 0 rows you will get an error. In that case, the original row count from the last successful execute() or executemany() is retained. I would suggest modifying your code to check for zero rows and if that condition is met, simply don't call executemany() in that case! |
Closing due to lack of activity |
What is your version of Python? Is it 32-bit or 64-bit?
3.7.2 64 bit
What is your cx_Oracle version?
7.1.1
What OS (and version) is Python executing on?
Windows 10 / Centos 7
What is your Oracle Database version?
12.1c
I have same issue than in #193 issue, but the Python version and cx_Oracle version is newer. The cursor.rowcount value doesn't reset.
The text was updated successfully, but these errors were encountered: