0

I want to submit the input (users info) into the users table, but getting operational errors.

  from tkinter import *
    from tkinter.messagebox import *
    import sqlite3

def submit():
    connect = sqlite3.connect(r'D:\ACCTGSYSTEM.db')
    c = connect.cursor()
    c.executemany('INSERT INTO users(Fname, Lname, Uname, Pass) VALUES (?,?,?,?,)',(fname.get(),lname.get(),uname.get(),passw.get()))

SCREEN SHOT OF OUTPUT

amorsiko1987
  • 19
  • 1
  • 1
  • 5
  • I think you might have forgotten the ";"? – Remi Smirra Jan 20 '16 at 16:39
  • remove the last comma in `(?,?,?,?,)` – thebjorn Jan 20 '16 at 16:42
  • this seems to have nothing to do with tkinter. You should remove that from the code, and remove the tkinter tag. – Bryan Oakley Jan 20 '16 at 16:49
  • Thanks for that but another Error appeared: sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 4, and there are 2 supplied. – amorsiko1987 Jan 20 '16 at 16:50
  • @bryan I have a form which uses tkinter – amorsiko1987 Jan 20 '16 at 16:51
  • @amorsiko1987 you have problem with SQL not with tkinter. You could remove all tkinter code and still have the same problem. – furas Jan 20 '16 at 18:22
  • maybe `print(fname.get(),lname.get(),uname.get(),passw.get())` to see what values you have. – furas Jan 20 '16 at 18:24
  • doesn't `executemany` expect `many` sets of data ? and even you have one set of data shouldn't you use list of sets `[ (fname.get(),lname.get(),uname.get(),passw.get()), ]` ? (http://stackoverflow.com/questions/5331894/i-cant-get-pythons-executemany-for-sqlite3-to-work-properly) – furas Jan 20 '16 at 18:29
  • @furas print(fname.get(),lname.get(),uname.get(),passw.get()). output exact data i have entered on the text box. What I dont understand is why Im getting problem inserting these data into the database – amorsiko1987 Jan 22 '16 at 00:40

1 Answers1

0

I can't check it.

See word many in word executemany().

executemany("...", data) expects list with many sets of data like this

data = [ 
    (fname1, lname1, uname1, passw1), 
    (fname2, lname2, uname2, passw2), 
    (fname3, lname3, uname3, passw3), 
]

If you have one set of data you still have to use list

data = [ 
    (fname1, lname1, uname1, passw1), 
]

not single set of data

data = (fname1, lname1, uname1, passw1)

Or use execute("...", data) with single set of data

data = (fname1, lname1, uname1, passw1)

see example with executemany in doc: https://docs.python.org/2/library/sqlite3.html

furas
  • 134,197
  • 12
  • 106
  • 148