我有一个代码来检查他/她是否是一个管理员,但我该如何检查数据库中的数字是否高于要求?
表中的字段名为adminlevel
def login():
def loggedin():
if adminlevel > 0:
print("Hello There Admin!")
print("Commands: Bet, Deposit, Logout")
print("Admin Commands: Ban, Give Credits")
else:
print("Hello there {}".format(username))
print("Commands: Bet, Deposit, Logout")
adminlevel = 0
username = input("Please enter your username: ")
password = getpass("Please enter your password: ")
admin = c.execute("select 1 from accounts where adminlevel > 0")
c.execute("select 1 from accounts where username = ? and password = ?", (username, password))
if c.fetchone():
print('Hello there! {}'.format(username))
loggedin()
else:
print("Username and Password Not Found!")
login()
if c.fetchone():
c.execute("select 1 from accounts where adminlevel > 0")
if c.fetchone():
print("Hello There Admin!")
print("Commands: Bet, Deposit, Logout")
print("Admin Commands: Ban, Give Credits")
else:
loggedin()
刚刚这样做了,忘记了它的工作原理与我的登录相同