TypeError:“ BaseQuery”对象不可调用Flask [英] TypeError: 'BaseQuery' object is not callable Flask
本文介绍了TypeError:“ BaseQuery”对象不可调用Flask的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我收到此错误:
TypeError: 'BaseQuery' object is not callable
这是我的代码:
companies = Company.query.all()
return Company.query(func.count(Company.id))
我需要找出Company模型中的行数。
请帮忙!
I need to find out number of rows in Company model. Please help!
推荐答案
Company.query
不可调用那里。如果您已经用 companies = Company.query.all()
选择了所有公司,为什么不简单使用 len(companies)
?
Company.query
isnt callable there. If you've already selected all your companies with companies = Company.query.all()
, why not simply use len(companies)
?
如果您不想/需要检索数据,则可以使用 Company.query.count( )
If you dont want/need to retrieve the data, you can get just the count with Company.query.count()
这篇关于TypeError:“ BaseQuery”对象不可调用Flask的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文