Reputation: 608
I need to print the row count of the cursor while using select query using python. But it always returns -1 even the select query returns some values.
Code I've tried:
cursor = conn.cursor()
cursor.execute(query)
print(cursor.rowcount)
How to print the rowcount of the cursor?
Upvotes: 1
Views: 389
Reputation: 608
The below code returns the lenth of the row.
rows = cursor.fetchall()
len(rows)
Upvotes: 1