简体   繁体   English

类型错误:参数 1 必须是 str,而不是元组

[英]TypeError: argument 1 must be str, not tuple

I received this error when trying to select columns from an SQLite3 DB, where the column 'Username' was the same as the variable 'username' and the column 'Password' was the same as the variable 'EncMessage' (Both the password and username was inputted by a user through a Tkinter entry box.我在尝试从 SQLite3 数据库中访问 select 列时收到此错误,其中“用户名”列与变量“用户名”相同,“密码”列与变量“EncMessage”相同(密码和用户名由用户通过 Tkinter 输入框输入。

When I ran the program and inputted a valid username and password into the entry boxes, I received this error 'line 3139, in signin c.execute(("SELECT Username, Password FROM Customers WHERE Username =? AND Password =?", username, encMessage,)) TypeError: argument 1 must be str, not tuple'当我运行程序并在输入框中输入有效的用户名和密码时,我在登录 c.execute(("SELECT Username, Password FROM Customers WHERE Username =? AND Password =?", username , encMessage,)) TypeError: argument 1 must be str, not tuple'

Any help would be appreciated.任何帮助,将不胜感激。

# 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")


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

has double parenthesis, remove 1 layer.有双括号,去掉一层。

Edit: Next time you ask questions, provide full traceback and tell us which line is it.编辑:下次你提问时,提供完整的回溯并告诉我们它是哪一行。 You are making helping you harder than it should be.你让帮助你变得比应该做的更难。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用按钮插入数据库会创建类型错误:参数 1 必须是 str,而不是元组 - Inserting into database using pushbutton creates TypeError: argument 1 must be str, not tuple 获取类型错误:在数据库中搜索时参数 1 必须是 str,而不是元组 - Getting TypeError: argument 1 must be str, not tuple when searching in DB TypeError: write() 参数必须是 str,而不是元组 | 写线(l) - TypeError: write() argument must be str, not tuple | writelines(l) Tkinter类“必须不是元组” TypeError Python - Tkinter Class “must be str not tuple” TypeError Python TypeError:元组索引必须是整数,而不是 str - TypeError: tuple indices must be integers, not str Python MySQL TypeError:必须是str,而不是元组 - Python MySQL TypeError: must be str, not tuple 类型错误:元组索引必须是整数或切片,而不是 str - TypeError: tuple indices must be integers or slices, not str 类型错误:尝试从 mysql 数据库获取数据时,write() 参数必须是 str,而不是元组 - TypeError: write() argument must be str, not tuple when trying to fetch data from the mysql db QComboBox.curfrentText() 不工作 - 我总是得到 TypeError: execute() argument 1 must be str, not tuple - QComboBox.curfrentText() not working - i always get TypeError: execute() argument 1 must be str, not tuple TypeError TypeError:connect() 参数 3 必须是 str,而不是 list - TypeError TypeError: connect() argument 3 must be str, not list
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM