繁体   English   中英

如何使用peewee插入数据?

[英]How to insert data using peewee?

我已经描述了皮尤人的模型:

class Products(peewee.Model):
    article = peewee.CharField(primary_key=True)
    name = peewee.CharField()
    price = peewee.FloatField()
    price_distributor = peewee.FloatField()
    price_discount = peewee.FloatField()

    class Meta:
        database = get_db_connection()

然后尝试插入如下数据:

row = {
                'article': row[0].value,
                'name': row[1].value,
                'price': row[2].value,
                'price_distributor': row[3].value,
                'price_discount': row[4].value
            }

# Insert
Products.insert(row)

它没有给出任何错误,只是数据库为空

之后,您需要调用.execute()。 相同的更新和删除。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM