Reputation: 51
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)
I get this error:
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.
I have probably missed something really simple but hey :P
EDIT: It seems to work for my single char usernames but it fails when I try the ADMIN username hence the 5 bindings
Upvotes: 4
Views: 8209
Reputation: 473873
Pass the argument to execute()
as a tuple. Replace:
c.execute("SELECT * FROM logins WHERE usernames=(?)", (self.user))
with:
c.execute("SELECT * FROM logins WHERE usernames=(?)", (self.user, ))
Upvotes: 17