Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to Insert Data Contained in Entry Widgets on a GUI Correctly into SQL DB Created in Python?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 452
    Answer it

    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.

     

    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
        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.

 0 Answer(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: