0

I'm trying to add data to a database from a GUI and using SQLite and getting this error

Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\max\AppData\Local\Programs\Python\Python37\lib\tkinter__init__.py", line 1705, in call return self.func(*args) File "C:\Users\max\Documents\compsci stuff\NEW COMPSCI.py", line 196, in get_items C.execute(sql ,vari) sqlite3.OperationalError: near ")": syntax error

  def get_items(self,*args,**kwargs): #this function gets the items from the entry boxes

        self.carmake= self.carmake_e.get()

        self.carmodel= self.carmodel_e.get()

        self.regi= self.regi_e.get()

        self.colour= self.colour_e.get()

        self.cost= self.cost_e.get()

        self. tcost= self. tcost_e.get()

        self.sellprice= self.sellprice_e.get()

        self.assumedprofit= self.assumedprofit_e.get()

        if self.carmake == " or self.carmodel" == "== self.colour == ":
            print ("WRONG")
            TKInter.messagebox.showinfo("error", "please enter values for car make, model and colour")
        else:
            print ("solid m8")
            sql= "INSERT INTO inventory(car_make,car_model, registration_plate,colour,cost,total_cost,selling_price,assumed_profit) VALUES) (?,?,?,2,?,?,2,?)"
            vari=(self.carmake, self.carmodel,self.regi,self.colour,self.cost,self.tcost,self.sellprice,self.assumedprofit)
            C.execute(sql ,vari)
            C.execute(sql(self.name,self.carmake, self.carmodel, self.regi,self.colour, self.cost,self.tcost,self.sellprice,self.assumedprofit))
            conn.commit()
            tkinter.messagebox.showinfo("success", "succesfully added to databse!")

1 Answer 1

2

You have an extra parenthesis in this line

sql= "INSERT INTO inventory(car_make,car_model, registration_plate,colour,cost,total_cost,selling_price,assumed_profit) VALUES) (?,?,?,2,?,?,2,?)"

VALUES) should be VALUES.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.