I want to check if the input password is the same as that stored in the database but when I use bcrypt.checkpw()
it returns an error saying that it expects a string or byte because the SQL query returns a tuple. I can't find a way to convert the database response to a byte from a tuple to make it compatible.
sql = ''' SELECT password FROM user_data WHERE username=? '''
username = input('Input username: ')
password = bytes(input('Input Password: '), encoding='utf-8')
cur = conn.cursor()
cur.execute(sql, (username,))
rows = cur.fetchall()
for row in rows:
if bcrypt.checkpw(password, row):
details = (user_id, username, password)
print('logged in')
return details
break