为什么数据库的用户名和PIN部分未被识别?
# PHASE 2 (With Database) SQLite 3
# Define Connection and Cursor
connection = sqlite3.connect('Bank_Users.db')
cursor = connection.cursor()
# Create Users Table
command1 = """ CREATE TABLE IF NOT EXISTS
bank(pin INTEGER PRIMARY KEY , username text )"""
cursor.execute(command1)
# Add to Users/Bank
cursor.execute("INSERT INTO bank VALUES (7620, 'Kailas Kurup')")
cursor.execute("INSERT INTO bank VALUES (4638, 'Bethany Watkins')")
cursor.execute("INSERT INTO bank VALUES (3482, 'John Hammond')")
cursor.execute("INSERT INTO bank VALUES (3493, 'Melissa Rodriguez')")
cursor.execute("INSERT INTO bank VALUES (9891, 'Kevin Le')")
# Get Results / Querying Database
cursor.execute("SELECT username, pin FROM bank")
results = cursor.fetchall()
print(results)
# Check Database User Info
def read_from_db():
for row in cursor.fetchall():
if username in row:
if pin in row:
print ("Success")
else:
print("Invalid Pin")
**我正在尝试根据输入的用户名和PIN检查数据库。例如,如果输入了7620和Kailas Kurup以外的用户名和PIN,它将返回“无效”。但是我的代码无法识别,并且“用户名”和“ PIN”下有弯曲的线条。为什么会发生这种情况以及如何解决?我正在使用Visual Studio代码(VSCODE)。
# PHASE 2 (With Database) SQLite 3
# Define Connection and Cursor
connection = sqlite3.connect('Bank_Users.db')
cursor = connection.cursor()
# Create Users Table
command1 = """ CREATE TABLE IF NOT EXISTS
bank(pin INTEGER PRIMARY KEY , username text )"""
cursor.execute(command1)
# Add to Users/Bank
cursor.execute("INSERT INTO bank VALUES (7620, 'Kailas Kurup')")
cursor.execute("INSERT INTO bank VALUES (4638, 'Bethany Watkins')")
cursor.execute("INSERT INTO bank VALUES (3482, 'John Hammond')")
cursor.execute("INSERT INTO bank VALUES (3493, 'Melissa Rodriguez')")
cursor.execute("INSERT INTO bank VALUES (9891, 'Kevin Le')")
# Get Results / Querying Database
cursor.execute("SELECT username, pin FROM bank")
results = cursor.fetchall()
print(results)
# Check Database User Info
def read_from_db():
for row in cursor.fetchall():
if username in row:
if pin in row:
print ("Success")
else:
print("Invalid Pin")
** I'm trying to check the database based on the username and pin entered. For example if a username and pin other than 7620 and Kailas Kurup was entered, it would return "Invalid". But my code is going unrecognized and there are squiggly lines under "username" and "pin". Why is this happening and how do I fix it? I am using visual studio code (VScode).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论