Python Forum

Full Version: sqlite3.OperationalError: near "%": syntax error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
I see a missing paren to close out c.execute. Other than that, everything looks syntactically correct.
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.