【发布时间】:2018-07-26 12:19:01
【问题描述】:
我在 Peewee 中得到了这个查询:
return c = Products.get(Products.sku == article).get()
如何判断是否返回数据?
我试过了:
if c.count() > 0:
if len(c) > 0
它不适合我
这是完整的代码:
try:
r = self.isProductExist(row['sku'])
## if (r.count() == 0):
except peewee.DoesNotExist:
# Insert product
def isProductExist(self, article):
return Products.get(Products.sku == article).get()
【问题讨论】:
-
return c = Products.get(Products.sku == article).get()不是有效代码。只需执行c = Products.get(Products.sku == article).get()。你能详细说明你是怎么知道它不起作用的吗?它会给你一个错误吗? -
我把这个查询放在试试:
except peewee.DoesNotExist: -
用代码更新你的问题
-
@Gundama 对不起,我想我不明白你的问题。如果您提供更多代码,我相信这里有人可以提供帮助。
-
完成,查看问题
标签: python peewee flask-peewee