-2
I’m trying to make a simple system of login, would like the system to check the logins that are already registered in the database, so that you have no more than one equal registered. I am using the Sqlite3 as a bank.
I’m doing like this.
import sqlite3
banco = sqlite3.connect('sistema_cadastro.db')
cursor = banco.cursor()
cursor.execute("SELECT login FROM usuarios")
banco.commit()
tabela = cursor.fetchall()
print(tabela)
login = [tabela]
str(login)
if 'bruno' in login:
print('Encontrou! (: ')
else:
print('Não encontrou ): ')
banco.close()
I’m making a select login in the user table and giving a print
The print is showing the following information:
[('adm',), ('bruno',), ('teste',)]
Then I put a if
looking for 'Bruno' in the login list.
But he doesn’t, and always plays for the else
.
I would like to see a way for him to find the variable 'Bruno' in the login list'.
Do this in SQL, for example(I don’t know your data structure but),
SELECT login FROM usuarios where nome="bruno"
– Augusto Vasques