INSERTING into SQLite 3 with Python

I am trying to create a form using tkinter. I ran 8 parameters into the submit function below. All parameters came from Entry widgets. The database and table were already created(shown as comments). Below the code I show the error message I am getting. I’m guessing I have some sort of syntax issue in the way I added VALUES to c.execute. Anyone have some guidance on this?

c.execute("""CREATE TABLE students(

first_name TEXT

last_name TEXT

dob BLOB

email TEXT

address TEXT


notes TEXT

student_id TEXT


def submit(FirstName,LastName,DOB,Email,Address,PhoneNumber,Notes,StudentID):
conn = sqlite3.connect(‘student_db’)
c = conn.cursor()
c.execute(“INSERT INTO students VALUES (FirstName,LastName,DOB,Email,Address,PhoneNumber,Notes,StudentID);”)

#Create input fields
FirstNameEntry = Entry(root, width = 50)
LastNameEntry = Entry(root, width = 50)
DOBEntry = Entry(root, width = 50)
EmailEntry = Entry(root, width = 50)
AddressEntry = Entry(root, width = 50)
PhoneNumberEntry = Entry(root, width = 50)
NotesEntry = Entry(root, width = 50)
StudentIDEntry = Entry(root, width = 50)

#Place input fields
FirstNameEntry.grid(row = 1, column = 1)
LastNameEntry.grid(row = 2, column = 1)
DOBEntry.grid(row = 3, column = 1)
EmailEntry.grid(row = 4, column = 1)
AddressEntry.grid(row = 5, column = 1)
PhoneNumberEntry.grid(row = 6, column = 1)
NotesEntry.grid(row = 7, column = 1)
StudentIDEntry.grid(row = 8, column = 1)

#Create a submit button
SubmitButton = Button(root, text = “Submit”, command = lambda: submit(FirstNameEntry,LastNameEntry,DOBEntry,EmailEntry,AddressEntry,PhoneNumberEntry,NotesEntry,StudentIDEntry))
SubmitButton.grid(row = 9, column = 0, columnspan = 2)

Exception in Tkinter callback
Traceback (most recent call last):
File “C:\Users\Admin\anaconda3\lib\”, line 1892, in call
return self.func(*args)
File “C:\Users\Admin\pyscripts\Student Database\”, line 81, in
File “C:\Users\Admin\pyscripts\Student Database\”, line 30, in submit
c.execute(“INSERT INTO students VALUES (FirstName,LastName,DOB,Email,Address,PhoneNumber,Notes,StudentID);”)
sqlite3.OperationalError: no such column: FirstName

If I’ve followed you correctly you’re trying to replace FirstName and so on with the value of parameter FirstName is that right? You’ll need some kind of parameter substituion otherwise your string is just the literal characters so the sql db receives that information as-is, for example-


but I assume you’d want name replaced with the Python idenfitifer, name which contains the actual person’s name, e.g. “Bjarne”.

Bear in mind that parameter substitution should be done with the module specific replacement tools to avoid injection issues- sqlite3 — DB-API 2.0 interface for SQLite databases — Python 3.10.2 documentation

If you’re posting code to forums in the future please see How do I format code in my posts? as it makes the content much easier for others to read here.