While I am trying to insert a row to my table from the Tkinter Entry widget, I'm getting the following errors:
Due to failed processing format-processing; Python "StringVar" cannot be converted to a MySQL type.
This is our code so far :
conn = mysql.connector.connect(host="localhost", username="root", password="Try#$12", database="attendancesystem")
c = conn.cursor()
params = (crsVar.get(), sbVar.get(), yrsVar.get(), smVar.get(),
nVar.get(), rollVar, genVar.get(), dVar.get(),
eVar.get(), mobVar.get(), adVar.get(), rdVar.get())
)
sql_insert_query = '''INSERT INTO `students_detail`
(Course, Subject, Year, Semester, Name, Roll_No, Gender, DOB, Email, Mobile, add, Photo)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)'''
c.execute(sql_insert_query, params)
conn.commit()
conn.close()
It should take input from the Tkinter (Entry, Combobox and radio button) form and insert it into the database the Columns of the Table ( Course, Subject, Year, Semester, Name, Roll No, Gender, DOB, Email, Mobile, add, Photo )
And all the text variables for tkinter widgets are StringVar().
Please help me out.
What I have tried:
I tried different methods to solve this by seeing similar questions on StackOverflow or GitHub and by reading Documentation