Jeeva
Jeeva

Reputation: 4825

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;

Upvotes: 2

Views: 2449

Answers (1)

coleifer
coleifer

Reputation: 26245

Video.select().count()

Issues a SELECT COUNT(1) FROM video query.

Upvotes: 4

Related Questions