Understand rowcount behavior for SELECT and DML statements
masterThe rowcount attribute in vertica_python behaves differently than standard DBAPI implementations:
SELECT statements
Immediately after a SELECT execution, cur.rowcount will be -1, indicating the row count is unknown. The value is updated incrementally as data is streamed from the server.
DML statements (INSERT, UPDATE, DELETE)
After executing a DML statement, cur.rowcount will initially be -1. To retrieve the actual number of affected rows, you must fetch the result as a single-element row.
# SELECT behavior
cur.execute('SELECT 10 things')
print(cur.rowcount) # -1
cur.fetchone()
print(cur.rowcount) # 1
# DML behavior
cur.execute("DELETE 3 things")
print(cur.rowcount) # -1
print(cur.fetchone()[0]) # 3