-1
I am trying to practice creating a small program with LOGIN SCREEN. This program has access to a MYSQL database and I want to VALIDATE the login data to allow entry.
I’m trying to learn on my own and having a lot of difficulties. It happens that when I try to enter with a user that already exists in the bank, but error the password, the program works normal. However, when I try a LOGIN that is not in the bank, the program displays this error. I could not find solution yet.
login_user = tela_login.lineEdit.text()
senha_user = tela_login.lineEdit_2.text()
cursor = banco.cursor()
cursor.execute(
"SELECT senha FROM quadro_funcionarios WHERE login = '{}'".format(login_user))
senha_banco = cursor.fetchone()
if senha_user == senha_banco[0]:
tela_login.close()
menu_principal.show()
The error generated is this:
22 senha_banco = cursor.fetchone()
23
24 if senha_user == senha_banco[0]: #Erro nesta linha aqui.
25 tela_login.close()
26 menu_principal.show()
Typeerror: 'Nonetype' Object is not subscriptable
I’m looking everywhere, how to solve, but I don’t understand the mistake.
probably the value of pass_bank is
None
.– Danizavtz
You can edit the question to include your query, and better explain the problem.
– Danizavtz
Thank you. I just did that.
– João
You are looking for a user that DOES NOT EXIST in your bank. You have to check if something comes there. Probably comes a
None
as @Danizavtz commented. Ai tu ta trying to access aNone[0]
, makes sense?– Shinforinpola