sqlite3.OperationalError: near ".": syntax error

by A3TNIP   Last Updated October 09, 2019 15:26 PM

sqlite3.OperationalError: near ".": syntax error this error comes while i try to fill the form

terminal: Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\tkinter__init__.py", line 1705, in call return self.func(*args) File "c:\Users\username\Desktop\Store Accounting Software\add_to_dy.py", line 64, in get_items c.execute(sql, (self.name, self.Stock,self.CP, self.SP, self.Total_CP, self.Total_SP, self.Assumed_Profits, self.Vendor, self.Vendor_no)) sqlite3.OperationalError: near ".": syntax error

i have looked up all of the similar problems here but couldn't find a solution to it. Here is the source code i'd appreciate some help

form tkinter import *

import sqlite3

import tkinter.messagebox

conn = sqlite3.connect(r"C:\Users\AAJU\Desktop\Store Accounting

Software\Database\store.db")

c = conn.cursor()

class Database:

def __init__ (self, master, *args, **kwargs):

    self.master = master
    self.heading = Label(master, text = "Add to the database", font=('arial 40 bold'), fg='steelblue')
    self.heading.place(x=400, y=0)        
    self.name_l = Label(master, text="Enter Product Name", font=("arial 18 bold"))
    self.name_l.place(x=0, y=70)
    self.Stock_l = Label(master, text="Enter Stocks", font=("arial 18 bold"))
    self.Stock_l.place(x=0, y=120)
    self.CP_l = Label(master, text="Enter Cost Price", font=("arial 18 bold"))
    self.CP_l.place(x=0, y=170)
    self.SP_l = Label(master, text="Enter Selling Price", font=("arial 18 bold"))
    self.SP_l.place(x=0, y=220)
    self.Vendor_l = Label(master, text="Enter Vendor Name", font=("arial 18 bold"))
    self.Vendor_l.place(x=0, y=270)
    self.Vendor_no_l = Label(master, text="Enter Vendor Phone Number", font=("arial 18 bold"))
    self.Vendor_no_l.place(x=0, y=320)

    # Entries
    self.name_e = Entry(master, width=25, font = ("arial 18 bold"))
    self.name_e.place(x=380, y=70)
    self.Stock_e = Entry(master, width=25, font = ("arial 18 bold"))
    self.Stock_e.place(x=380, y=120)
    self.CP_e = Entry(master, width=25, font = ("arial 18 bold"))
    self.CP_e.place(x=380, y=170)
    self.SP_e = Entry(master, width=25, font = ("arial 18 bold"))
    self.SP_e.place(x=380, y=220)
    self.Vendor_e = Entry(master, width=25, font = ("arial 18 bold"))
    self.Vendor_e.place(x=380, y=270)
    self.Vendor_no_e = Entry(master, width=25, font = ("arial 18 bold"))
    self.Vendor_no_e.place(x=380, y=320)

    #Button to add to database
    self.btn_add = Button(master, text='Add to database', width = 25, height=2, bg='steelblue', fg = 'white', command=self.get_items)
    self.btn_add.place(x=520, y = 370)

    #Text Box
    self.tbox = Text(master, width=60, height=18)
    self.tbox.place(x=750, y=70)
def get_items(self,*args, **kwargs):
    #get from entries
    self.name = self.name_e.get()
    self.Stock = self.Stock_e.get()
    self.CP = self.CP_e.get()
    self.SP = self.SP_e.get()
    self.Vendor = self.Vendor_e.get()
    self.Vendor_no = self.Vendor_no_e.get()
    self.Total_CP=float(self.CP) * float(self.Stock)
    self.Total_SP=float(self.SP) * float(self.Stock)
    self.Assumed_Profits = float((self.Total_SP) - (self.Total_CP))

#After I added this block of code i got the error

    if self.name=='' or self.Stock=='' or self.CP=='' or self.SP=='':
        tkinter.messagebox.showinfo('Error','Required Field(s) empty')
    else:
        sql = "INSERT INTO inventory (Name, Stock, CP, SP, Total_CP, Total_SP, Assumed_Profits, Vendor, Vendor_No. ) VALUES(?,?,?,?,?,?,?,?,?)"
        c.execute(sql, (self.name, self.Stock,self.CP, self.SP, self.Total_CP, self.Total_SP, self.Assumed_Profits, self.Vendor, self.Vendor_no))
        conn.commit()
        tkinter.messagebox.showinfo('Success','Successfully Transferred into the database')

root = Tk()

b = Database(root)

root.geometry('1366x768+0+0')

root.title("Add to the database")

root.mainloop()



Answers 1


You have a period after Vendor_no

Vendor_No.

it needs to not be there.

HalR
HalR
October 09, 2019 15:25 PM

Related Questions



TypeError: unorderable types: int() < Label()

Updated April 18, 2018 10:26 AM

Open class from selected combobox

Updated April 25, 2019 13:26 PM