[docs] Please document sqlite3 return values
Bjartur Thorlacius
bjartur at adversary.io
Fri May 24 07:48:11 EDT 2019
Salut Julien.
Let's take a step back, and run Python 2.7 (not 3.7) in a MSYS2
(MinGW+Cygwin) Bash shell on Windows 10. Python 2 fetchone is documented
as returning None, just like Python 3 fetchone.
Mótherji at Lappi MINGW64 /tmp/pysql
$ python -V
Python 2.7.15
Mótherji at Lappi MINGW64 /tmp/pysql
$ cat users.db
cat: users.db: No such file or directory
Mótherji at Lappi MINGW64 /tmp/pysql
$ cat users.py
from sqlite3 import connect as database
username='Nonexistant'; password='should not match'
user_database = database('users.db', isolation_level=None)
database_cursor = user_database.cursor()
database_cursor.execute('CREATE TABLE users(username text, password text)')
result = database_cursor.execute("SELECT count(*) FROM users WHERE
username=? AND password=?;", (username, password)).fetchone()
print(result)
print(result[0])
print(result[0] > 0)
Mótherji at Lappi MINGW64 /tmp/pysql
$ python users.py
(0,)
0
False
So even without Python 3 and Docker, I see the same mismatch between
documenation and behaviour on my laptop.
Meilleures salutations,
Bjartur
More information about the docs
mailing list