I'm making a python sql program for a project, and am having issues with login errors. Here's the whole login section
print("Welcome to the program")
while True:
print("If this is your first time playing, you may create an account. If not, log in to an existing one. login/create. If you'd like to exit, type in exit.")
answer = input()
if answer == 'login':
while True:
db = sqlite3.connect('data/users')
cursor.execute('''
CREATE TABLE IF NOT EXISTS users(id INTEGER PRIMARY KEY, username TEXT,
password TEXT, score TEXT)
''')
username = input("Insert username")
password = input("Insert password")
id = cursor.lastrowid
user_search = cursor.fetchall('''SELECT * FROM users WHERE id = 1 AND username = ? AND password = ?''', (username, password))
cursor.execute(user_search[(username),(password)])
data=cursor.fetchall()
if data is None:
print("Nothing found with an id of 1, nor are there matchign results for the username and password.")
else:
print("None found.")
#https://stackoverflow.com/questions/2440147/how-to-check-the-existence-of-a-row-in-sqlite-with-python Code reference, this site helped me find out what I was doing wrong
elif answer == 'create':
print("You may create an account if there are none.")
username = input("Create a new username. Case sensitive.")
password = input("Create a new password. Case sensitive.")
user_search = cursor.execute('''SELECT * FROM users WHERE id = 1 AND username = ? AND password = ?''', (username, password))
result = cursor.fetchall()
cursor.execute(user_search[(username),(password)])
if result:
for i in result:
print("There is only one user slot allowed. Said slot is taken. You may not create an account.")
break
else:
print("User slot free. Appending credentials. You have created an account.")
credentials =[(username),(password)]
cursor.executemany('''INSERT INTO users(username, password) VALUES(?,?)''', (users))
else:
print("Input not recognised.")
Specifically, this section:
username = input("Insert username")
password = input("Insert password")
id = cursor.lastrowid
user_search = cursor.fetchall('''SELECT * FROM users WHERE id = 1 AND username = ? AND password = ?''', (username, password))
cursor.execute(user_search[(username),(password)])
data=cursor.fetchall()
if data is None:
print("Nothing found with an id of 1, nor are there matching results for the username and password.")
else:
print("None found.")
I'm not used to coding with python, so I don't know why I'm getting these errors. SQL is fairly new to me also. I'm getting a "fetchall takes 0 arguments 2 given" and I haven't been able to find a viable solution