sqlite3.ProgrammingError:提供的绑定数量不正确.当前语句使用1个,提供了5个 [英] sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 1, and there are 5 supplied
本文介绍了sqlite3.ProgrammingError:提供的绑定数量不正确.当前语句使用1个,提供了5个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一生都无法弄清楚为什么这是失败的,我知道代码很丑,但我只需要将它用于学校项目.
I can not for the life of me figure why this is failing, ugly code I know but I just need to put it out for a school project.
def changeusername(self,i):
user="self.user=self.username"+str(i)+".get()"
exec(user)
print(self.user)
record1=list(c.execute("SELECT * FROM logins WHERE usernames=(?)",(self.user)))
print(record1)
我收到此错误:
line 428, in changeusername
record1=list(c.execute("SELECT * FROM logins WHERE usernames=(?)",(self.user)))
sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 1, and there are 5 supplied.
我可能错过了一些非常简单的东西,但是嘿:P
I have probably missed something really simple but hey :P
它似乎适用于我的单字符用户名,但是当我尝试使用 ADMIN 用户名时它失败了,因此有 5 个绑定
It seems to work for my single char usernames but it fails when I try the ADMIN username hence the 5 bindings
推荐答案
将参数作为元组传递给 execute()
.替换:
Pass the argument to execute()
as a tuple. Replace:
c.execute("SELECT * FROM logins WHERE usernames=(?)", (self.user))
与:
c.execute("SELECT * FROM logins WHERE usernames=(?)", (self.user, ))
这篇关于sqlite3.ProgrammingError:提供的绑定数量不正确.当前语句使用1个,提供了5个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文