Reputation: 93
i keep getting this error when i try to add a column and give it a name
sqlite3.OperationalError: near "100": syntax error
here is my code (minimal)
from tkinter import *
import sqlite3
from tkinter import messagebox
conr = sqlite3.connect("CE.db")
curr = conr.cursor()
rt = Tk()
def add():
ID = e30.get()
curr.execute('alter table cust add {}'.format(ID))
lbl30 = Label(rt, text= "Your ID")
lbl30.grid (row = 0, column = 0)
e30 = Entry(rt, width = 30)
e30.grid(row = 0, column = 1)
buttt1 = Button(rt, text = 'Submit', command = add, width = 20)
buttt1.grid(row = 1, column = 0, columnspan = 2)
rt.mainloop()
can someone please tell me what i am doing wrong and how i can fix it.
Upvotes: 1
Views: 636
Reputation: 2109
The line
curr.execute('alter table cust add {}'.format(ID))
is being formatted and executed as
alter table cust add 100
This is not valid SQLite syntax The correct syntax can be found at: SQlite Alter Syntax
Upvotes: 1