Bottom Page

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
Quote
#2
I see a missing paren to close out c.execute. Other than that, everything looks syntactically correct.
Quote
#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.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  syntax error on return statement l_butler 5 86 May-31-2020, 02:26 PM
Last Post: pyzyx3qwerty
  Syntax Error with = sign and more Kathleen57 3 208 May-03-2020, 03:52 AM
Last Post: buran
  Syntax Error Invalid Syntax / ghost Variable Atlaas 2 207 Apr-14-2020, 11:48 PM
Last Post: Atlaas
  Python 3.7, Windows 7, Syntax Error hughdent 1 258 Mar-23-2020, 10:09 AM
Last Post: buran
  Syntax error oguzcan 10 537 Mar-17-2020, 07:37 PM
Last Post: Larz60+
  Syntax error gray1306 4 250 Mar-08-2020, 09:38 PM
Last Post: deanhystad
  Syntax error - precedence Rev2k 3 313 Jan-03-2020, 08:36 PM
Last Post: Rev2k
  Keep getting "invalid syntax error" jpringle1 3 555 Dec-25-2019, 04:43 PM
Last Post: Gribouillis
  'invalid syntax' error rix 3 355 Dec-12-2019, 11:14 PM
Last Post: stullis
  Syntax Error (elif statement) Kanashi 0 479 Nov-20-2019, 11:29 PM
Last Post: Kanashi

Forum Jump:


Users browsing this thread: 1 Guest(s)