I have a sqlite table with 3 columns (id, username, password). There is 1 row in the table. I am trying to run a sqlite query to select the id where the username and password match what the user entered. My code for login.py is as follows:
import sqlite3 as lite
def login(userinput, userpass):
con = lite.connect('console.db')
with con:
cur = con.cursor()
cur.execute("SELECT id FROM users WHERE username == :userinput & password == :userpass", {"userinput": userinput, "userpass": userpass})
con.commit()
row = cur.fetchone()
print row[0]
my code for main.py is as follows:
import login
from getpass import getpass
import hashlib
username = raw_input("username >>")
password1 = getpass("password >>")
password1 = hashlib.sha224(password1).hexdigest()
login.login(username, password1)
I get the error message as follows:
Traceback (most recent call last):
File "/home/wip/PycharmProjects/console/main.py", line 9, in <module>
login.login(username, password1)
File "/home/wip/PycharmProjects/console/login.py", line 12, in login
print row[0]
TypeError: 'NoneType' object has no attribute '__getitem__'
My password that is stored in the table is stored using sha224 encryption, just as the user inputted password when prompted. Any help with this would be greatly appreciated!
fetchone()returnsNonewhen no matching row is found.