Oct-25-2020, 11:23 PM
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
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
