What to do to ensure that values from Tkinter form is being entered into MySQL table instead of getting an error message?

  mysql, mysql-python, python, tkinter, tkinter-entry

I’ve made a tkinter form that’s supposed to enter values into a MySQL table. However, when i enter the appropriate values int the form, I get the error message created by me ("All fields are required"). In the following code, a=task_name.get() [string], b=student_subject.get() [string], c=due_date.get() [int], d=priority.get() [int], e=task_type.get() [string], and f=date_added.get() [int].

”’
def action():

    if a=="" or b=="" or e=="":
        messagebox.showerror("Error" , "All fields are required" , parent = wintask)
    else:
        con = mysql.connect(host="localhost", user="root", password="12345678", database="ibcomputerscience")
        cur = con.cursor()
        cur.execute("INSERT INTO task_info(student_subject, task_name, due_date, priority, task_type, date_added) VALUES(%s,%s,%s,%s,%s,%s)",(a, b, c, d, e, f))
        con.commit()
        con.close()
        messagebox.showerror("Success" , "Task Added Successfully", parent = wintask)

”’

I’ll appreciate any help/insight. Thank you!

Source: Python Questions

LEAVE A COMMENT