python TypeError:参数1必须是字符串,而不是元组

hec6srdp  于 2023-01-16  发布在  Python
关注(0)|答案(1)|浏览(196)

我在尝试从SQLite3 DB中选择列时收到此错误,其中列“Username”与变量“username”相同,列“Password”与变量“EncMessage”相同(密码和用户名都是用户通过Tkinter输入框输入的。
当我运行程序并在输入框中输入有效的用户名和密码时,我收到了此错误'行3139,in signin c.execute((“SELECT Username,Password FROM Customers WHERE Username =?AND Password =?",用户名,encMessage,))类型错误:参数1必须是字符串,而不是元组“
任何帮助都将不胜感激。

# SignIn Function
def signin():
    username = user.get()
    password = pass.get()
    check_pass = password 
    
    reg = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!#%*?&]{6,20}$"
    
    # Compiling regex 
    pat = re.compile(reg)

    # Searching regex
    mat = re.search(pat,password)

    # Validation conditions
    if mat and password == check_pass:
        message = password 
        
        key = Fernet.generate_key()
        
        fernet = Fernet(key)

        encMessage = fernet.encrypt(message.encode())
        
        decMessage = fernet.decrypt(encMessage).decode()
        
        if check_pass == decMessage:

            conn = sqlite3.connect('CustomersTTA.db')

            # Create a cursor instance
            c = conn.cursor()

            c.execute("Select rowid, * FROM Customer")
            records = c.fetchall()

            c.execute(("SELECT Username,Password FROM Customers WHERE Username = ? AND Password = ?", username, encMessage,))
         
            if not c.fetchone():
                messagebox.showerror("Invalid","Credentials are incorrect")
            else:
                print("Welcome")
eqzww0vc

eqzww0vc1#

c.execute(("SELECT Username,Password FROM Customers WHERE Username = ? AND Password = ?", username, encMessage,))

有双括号,删除1层。
编辑:下次你提问时,请提供完整的追溯,并告诉我们是哪一行。你让帮助你变得比应该的更难了。

相关问题