Search code examples
pythonsqliteflask-peewee

How get number of rows from peewee database?


I only need to get the number of rows from the peewee database. I know that .count or .wrapped_count can be executed in a query.

num_of_rows = Video.select().wrapped_count()

I need to execute a select query to get the number of rows. Does it affect performance and is there any method or field that I can use to get how many rows exist in the database?

In raw SQL query, I could write it like this.

SELECT COUNT(*) FROM video;

Solution

  • Video.select().count()
    

    Issues a SELECT COUNT(1) FROM video query.