• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

SQL and GUI's in python  RSS feed

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the code below the entry widgets that I use the get method to retrieve data from, have been created earlier in the code.

I have tried the following ways to solve the problem:

turning the list into a tuple
using a list literal
inserting data as variables into the database rather than as a list
getting the data from entry widgets inserting it into python variables, then I inserted the python variables into a list variable and then tried to insert this list variable into the sql database I created

# declares and defines function that checks that data in the 'Password' and ' Confirm Password' entries match
def MatchingPasswordsValidator(): if str(PasswordEntry.get())!= str(ConfirmPasswordEntry.get()): tkinter.messagebox.showerror("","Please ensure the passwords you enter match") else: # declares list variable UserDetails = []

   # populates list variable

   # inserts user's details into the program's database
   c.executemany("INSERT INTO tblUserDetails VALUES(?,?,?,?)",UserDetails)
   # saves changes made to database
File "C:\Users\User\Documents\School\CS\Project\Screen2.py", line 135, in MatchingPasswordsValidator c.executemany("INSERT INTO tblUserDetails VALUES(?,?,?,?)",UserDetails) sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 4, and there are 1 supplied.
Posts: 20568
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A word of advice. Don't start variable names in Python with upper-case letters. In almost no programming language is this recommended - at least unless you're programming an old-style mainframe with punched cards!

As a general rule, objects, properties and identifiers should begin with lower case. Upper-case is reserved for things like class names (for object-oriented languages).

Your query fails because executemany wants a tuple to hold the arguments, not an array.

Try this, instead - note that I've adjusted names per recommended conventions:

I do have to ask why you are saving confirmPassword, though. You shouldn't be storing at all unless the confirmPassword is the same as password, in which case, storing 2 copies of an always-identical object is A) a waste of space and B) a potential source for bugs.

Also, another good practice is to explicitly name what you are inserting, just to avoid possible problems in the event that the database schema gets changed. And in my experience, that's quite common. So:
Weeds: because mother nature refuses to be your personal bitch. But this tiny ad is willing:
global solutions you can do at home or in your backyard
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!