尝试添加到.db文件时出现Python SQLite错误

尝试添加到.db文件时出现Python SQLite错误,python,sqlite,Python,Sqlite,我在运行程序并尝试插入数据时遇到此错误: 'sqlite3.OperationalError: near ")": syntax error' 我的代码如下: import sqlite3 def insert_data(values): with sqlite3.connect("mrsimms.db")as db: cursor = db.cursor() sql ='Insert into Stock(Name,Type,RetailPrice,N

我在运行程序并尝试插入数据时遇到此错误:

'sqlite3.OperationalError: near ")": syntax error'
我的代码如下:

import sqlite3
def insert_data(values):
    with sqlite3.connect("mrsimms.db")as db:
        cursor = db.cursor()
        sql ='Insert into Stock(Name,Type,RetailPrice,NumberInStock,)values(?,?,?,?,?)'
        cursor.execute(sql,values)
        db.commit()

if __name__ == "__main__":
    add = "y"
    while add == "y":
        Name = input("Please enter the Name: ")
        Type = input("Please enter the type of product: ")
        RetailPrice =input("Retail Price: ")
        NumberInStock = input('Please enter the amount in stock: ')
        AddNewStock = (ProductID,Name,Type,RetailPrice,NumberInStock)
        print(AddNewStock)
        insert_data(AddNewStock)
        add = input("Do you wish to add another record? (y/n) ")
        print()

任何帮助都将不胜感激

您忘记定义ProductID了吗?不应该
sql='Insert into Stock(Name,Type,RetailPrice,numberstock,)value(?,,,,,?,?)
be
sql='Insert into Stock(Name,Type,RetailPrice,numberstock,ProductID)value(?,,,,?)
我把ProductID放在那里,它会自动把一个数字放在那里。我删除了它,但是它仍然不起作用删除
NumberStock
值之间的逗号(
sql='INSERT INTO Stock(名称、类型、零售价格、NumberStock)值(?,,,,,,?)'