I'm writing code for a project, and when using SQLite3 I came across this error that I can't seem to fix.
I've looked up the answer before, but it always seems to be a case of the SQLite reading a variable as a column title, but here the column it can't find isn't one of my variables so I'm a bit lost.
I am attempting to insert data from variables into an SQLite database, and while at first I got a simpler version working okay, now that I try and integrate it into my full code I'm getting stuck again.
Here's a trial version that I'm using to get the whole thing working before I try and use it properly:
c.execute("CREATE TABLE TEST (GIFNAME, TagStyle, TagEvent, TagTime)")
def SaveStyle():
if (GIFName.get() != "") and (TagStyle.get() != ""):
#print(GIFName.get(), ", ", TagStyle.get(), ", ", TagEvent.get(), ", ", TagTime.get())
#Saved1=tk.Label(window4, text="Saved!", fg="#ffffff", bg="#D0CEC2")
#Saved1.grid(row=9, column=1)
c.execute("INSERT INTO TEST VALUES (%s,%s,%s,%s)" %(GIFName2, TagStyle2, TagEvent2, TagTime2))
conn.commit()
c.execute("select * from TEST")
print(c.fetchall())
I know the code isn't great, I'm relatively new to coding so it's not exactly perfect, I just want to get that one part fixed because it will be used for quite a few parts of my program.
The 4 variables its grabbing are being used because the original ones are tk.StringVar()
and the sqlite kept coming back saying they were unsupported.
Here is the full error message:
"Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python33\lib\idlelib\run.py", line 109, in main
seq, request = rpc.request_queue.get(block=True, timeout=0.05)
File "C:\Python33\lib\queue.py", line 175, in get
raise Empty
queue.Empty
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python33\lib\tkinter\__init__.py", line 1475, in __call__
return self.func(*args)
File "N:\PYTHON\Alice Program\trial.py", line 16, in SaveStyle
c.execute("INSERT INTO TEST VALUES (%s,%s,%s,%s)" %(GIFName2, TagStyle2, TagEvent2, TagTime2))
sqlite3.OperationalError: no such column: PY_VAR0"
(Sorry I had to format this as code, it wouldn't let me post it as a quote)
Originally I was using ?
instead of %s
but it kept saying my variables were unsupported, and a friend is using %s
and got it working, but she can't remember what she did, and now she's lost the file so I can't try and use it for help.
Thanks in advance for your help, and if I've missed any information, let me know.