Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
save button: IndexError
#1
So my app can successfully export to csv file and import it. But when I try to save the data into the DB I'm getting error.
One note: when I import the csv file there is extra one empty row.

IndexError: list index out of range

Here is my function for save buton

        def savedb():
            if messagebox.askyesno('Confirm', 'Are you sure you want to save the data into the Database?'):
                try:
                    
                    for i in mydata:
                        sid = i[0]
                        fname = i[1]
                        surname = i[2]
                        idc = i[3]
                        query = "INSERT INTO student_questioner(student_id, student_name, student_surname, student_card, student_score) VALUES (NULL, ?, ?, ?,?) "
                        cur.execute(query, (sid,fname, surname, idc))
                    con.commit()
                    clear()
                    messagebox.showinfo('Data Saved', 'Data has been saved to the database!')
                except EOFError as a:
                    messagebox.showerror(a)
            else:
                return False
Reply


Messages In This Thread
save button: IndexError - by Maryan - Oct-25-2020, 11:23 PM
RE: save button: IndexError - by bowlofred - Oct-25-2020, 11:40 PM
RE: save button: IndexError - by Maryan - Oct-26-2020, 12:21 AM
RE: save button: IndexError - by bowlofred - Oct-26-2020, 01:05 AM
RE: save button: IndexError - by Maryan - Oct-26-2020, 01:11 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  how to save to multiple locations during save cubangt 1 572 Oct-23-2023, 10:16 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020