Peewee选择Decimal字段?

时间:2018-02-03 01:32:46

标签: mysql python-3.x peewee

我使用Peewee库提出以下请求:

return Products.select(Products.price, Products.sku, Products.manufacturer_id).where(Products.sku == article).get()

其中Products.price是MySQL中类型为decimal(15,4)的字段

这是型号:

class Products(peewee.Model):
    product_id = IntegerField(primary_key=True)
    sku = peewee.CharField()
    model = peewee.CharField()
    price = peewee.DecimalField(max_digits=15, decimal_places=4)
    manufacturer_id = peewee.IntegerField()

    class Meta:
        database = get_db_connection()
        table_name = 'oc_product'

当我运行查询时如上所述,我收到错误:

Error has occurred: Cannot convert b'6403.0000' to Decimal

有什么问题?

1 个答案:

答案 0 :(得分:0)

我相信Peewee中有一个使用Python 3的错误。请告诉我这个补丁是否解决了您的问题:

https://github.com/coleifer/peewee/commit/cd07f4e01a1262166d8944736e11d0681fb76214