[docs] Please document sqlite3 return values

Julien Palard julien at palard.fr
Fri May 24 08:07:28 EDT 2019

Hi Bjartur,

fetchone returns None when no result are found but in your case (COUNT(*)) there's one result: the count, being equal to zero. A count will always return one result, the result being the actual count, so if there's one match you'll get (1, ) instead of (0, ), and so on.

To get no result, let's change the COUNT(*) to *:

>>> result = database_cursor.execute("SELECT * FROM users WHERE username=? AND password=?;", (username, password)).fetchone()
>>> print result

and you're getting None as documented.

It's the same behavior in Python 2 and 3. BTW you should think about upgrading to Python 3: Python 2 end of life is in 7 months, and Python 3 is more than 10 years old.

Julien Palard

More information about the docs mailing list