I am trying to get the rowcount
of a sqlite3
cursor
in my Python3k program, but I am puzzled, as the rowcount
is always -1
, despite what Python3 docs say (actually it is contradictory, it should be None
). Even after fetching all the rows, rowcount
stays at -1
. Is it a sqlite3
bug? I have already checked if there are rows in the table.
I can get around this checking if a fetchone()
returns something different than None
, but I thought this issue would be nice to discuss.
Thanks.
Best Solution
From the documentation:
That means all
SELECT
statements won't have arowcount
. The behaviour you're observing is documented.EDIT: Documentation doesn't say anywhere that
rowcount
will be updated after you do afetchall()
so it is just wrong to assume that.