Web2Py 插入数据库错误

Web2Py insert into database error

我正在尝试插入。这是我的代码:

db.define_table('orders',
            Field('idProduct', type = 'integer'),
            Field('quantity', type = 'integer'),
            Field('idUser', type = 'integer'),
            Field('status'),
            Field('order_date'),
            Field('product_price', type = 'integer'))

SQL:

sql = "Insert into orders (idProduct,idUser,quantity,status,order_date,product_price) values "
sql = sql + "(" + str(idProduct) + "," + str(idUser) + "," + str(quantity) + ",'cart','" + str(order_date)+ "," + str(product_price)+"')"

我收到以下错误:

<class 'sqlite3.OperationalError'> 5 values for 6 columns

我不明白哪里出了问题,因为如果我删除 product_price,一切正常。

谢谢。

您在最后一个右括号之前有额外的报价。删除它,它将修复错误:

sql = sql + "(" + str(idProduct) + "," + str(idUser) + "," +
str(quantity) + ",'cart','" + str(order_date)+ "," +
str(product_price)+")"