2

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;
Ahmad
  • 274
  • 2
  • 15
Jeeva
  • 3,975
  • 3
  • 23
  • 47

1 Answers1

4
Video.select().count()

Issues a SELECT COUNT(1) FROM video query.

coleifer
  • 24,887
  • 6
  • 60
  • 75