In pyodbc
, cursor.rowcount
works perfectly when using cursor.execute()
. However, it always returns -1
when using cursor.executemany()
.
How does one get the correct row count for cursor.executemany()
?
This applies to multiple inserts, updates, and deletes.
You can't, only the last query row count is returned from executemany, at least that's how it says in the pyodbc code docs. -1 usually indicates problems with query though. If you absolutely need the rowcount, you need to either cursor.execute in a loop or write a patch for pyodbc library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With