8

I am getting this error:

TypeError: 'BaseQuery' object is not callable

Here is my code:

companies = Company.query.all()
return Company.query(func.count(Company.id))

I need to find out number of rows in Company model. Please help!

larissa
  • 493
  • 4
  • 16
Rohit Dhiman
  • 208
  • 2
  • 3
  • 8

1 Answers1

3

Company.query isnt callable there. If you've already selected all your companies with companies = Company.query.all(), why not simply use len(companies)?

If you dont want/need to retrieve the data, you can get just the count with Company.query.count()

DazWorrall
  • 13,682
  • 5
  • 43
  • 37