Click here to Skip to main content
13,863,289 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
I am using a get method in python to retrieve the contents of entry widgets on a GUI I created, once a user presses a button, to tell the program that they have entered data into the entry widgets. I then append this data to a list and insert it as a record into an sql database created in python. However when I run my code I keep receiving the error shown below.

In the code below the str entry widgets that I use the get method to retrieve data from, have been created earlier in the code.
# 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
    UserDetails.append(str(FirstNameEntry.get()))
    UserDetails.append(str(SurnameEntry.get()))
    UserDetails.append(str(PasswordEntry.get()))
    UserDetails.append(str(ConfirmPasswordEntry.get()))

    # inserts user's details into the program's database
    c.executemany("INSERT INTO tblUserDetails VALUES(?,?,?,?)",UserDetails)
    # saves changes made to database
    conn.commit()
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.


What I have tried:

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
Posted
Updated 3 days ago
v3
Comments
Richard MacCutchan 12-Feb-19 4:10am
   
You need to provide the names of the variables individually, not as a list. From the message this looks like an sqlite3 restriction.
Richard Deeming 12-Feb-19 9:14am
   
Looks like you're storing passwords in plain text. Don't do that!

Secure Password Authentication Explained Simply[^]
Salted Password Hashing - Doing it Right[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web02 | 2.8.190214.1 | Last Updated 15 Feb 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100