I'm trying to create a login script using SQLite to store the user data. Any ideas on how to to that? I have research over hours and found nothing of the kind. I would appreciate any help! :)
This is what I got so far:
user = raw_input "User:"
pswd = getpass.getpass "Password"
db = sqlite3.connect('/SABB/DATASETS/SENHAS')
c = db.cursor()
c.execute('SELECT 1 from sabb WHERE usuario = "user"')
('SELECT 1 from sabb WHERE senha = "pswd"')
if c.fetchall() is True:
print "Welcome"
else:
print "Login failed"
But it always returns Login failed... I want to check the input "user" and the input "pswd" against the database and if they match, return Welcome.
I changed it to:
db = sqlite3.connect('/SABB/DATASETS/SENHAS')
c = db.cursor()
login = c.execute('SELECT * from sabb WHERE usuario = "user" AND senha = "pswd"')
if (login > 0):
print "Welcome"
else:
print "Login failed"
But I'm still getting Welcome every time. I also tried "if (login == 1)" but then it only returns Login failed.
fetchall()will never returnTrue.