Python Forum
sqlite3.OperationalError: near "%": syntax error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sqlite3.OperationalError: near "%": syntax error
#1
I am getting an error trying to connect to my SQLite database. I have tried several things and it is not working. I cannot figure out where the syntax error is, near self.Rating_var.get()))

#=======CONNECT TO SQLITE==========
    def add_film(self):
        conn = connect('patrick.db')
        c = conn.cursor()
        c.execute("insert into patrick values(%s,%s,%s,%s,%s,%s,%s,%s)",(self.Title_var.get(),
                                                                          self.Actors_var.get(),
                                                                          self.Directors_var.get(),
                                                                          self.Genre_var.get(),
                                                                          self.Summary_var.get(),
                                                                          self.Year_var.get(),
                                                                          self.Length_var.get(),
                                                                          self.Rating_var.get())
                                                                          
                                                                          
        con.commit()
        con.close()
Error:
Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\Gaming\AppData\Local\Programs\Python\Python37\lib\tkinter\__init__.py", line 1705, in __call__ return self.func(*args) File "C:/Film-Classic-Database/film1.py", line 147, in add_film self.Rating_var.get())) sqlite3.OperationalError: near "%": syntax error
Reply
#2
I see a missing paren to close out c.execute. Other than that, everything looks syntactically correct.
Reply
#3
Thank you. Yes, I added that parenthesis but still cannot figure out why it is not writing to my database when I click on add. It just gives me that error. Thank you for your help.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Syntax error for "root = Tk()" dlwaddel 15 1,012 Jan-29-2024, 12:07 AM
Last Post: dlwaddel
Photo SYNTAX ERROR Yannko 3 334 Jan-19-2024, 01:20 PM
Last Post: rob101
  sqlite3 Conn Insert Value Error TylerDunbar 3 676 Sep-04-2023, 06:32 PM
Last Post: deanhystad
  Syntax error while executing the Python code in Linux DivAsh 8 1,451 Jul-19-2023, 06:27 PM
Last Post: Lahearle
  Code is returning the incorrect values. syntax error 007sonic 6 1,136 Jun-19-2023, 03:35 AM
Last Post: 007sonic
  syntax error question - string mgallotti 5 1,251 Feb-03-2023, 05:10 PM
Last Post: mgallotti
  Syntax error? I don't see it KenHorse 4 1,194 Jan-15-2023, 07:49 PM
Last Post: Gribouillis
  Syntax error tibbj001 2 847 Dec-05-2022, 06:38 PM
Last Post: deanhystad
  Python-for-Android:p4a: syntax error in main.py while compiling apk jttolleson 2 1,777 Sep-17-2022, 04:09 AM
Last Post: jttolleson
  Mysql Syntax error in pymysql ilknurg 4 2,290 May-18-2022, 06:50 AM
Last Post: ibreeden

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020