[英]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.