Я делаю программу Python SQL для проекта, и у меня возникают проблемы с ошибками входа в систему.Вот весь раздел входа в систему
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.")
#/1769450/kak-proverit-nalichie-stroki-v-sqlite-s-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.")
В частности, этот раздел:
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.")
Я не привык к написанию кода на python, поэтому я не знаю, почему я получаю этиошибки.SQL довольно новый для меня тоже.Я получаю сообщение «fetchall принимает 0 аргументов, 2 дано», и мне не удалось найти жизнеспособное решение