Peewee: Checking record exist

Created on 16 Jun 2017  路  3Comments  路  Source: coleifer/peewee

I know about exception thrown in this regard, just want to know whether there's some count or exists() method to check whether some record returned or not?

Most helpful comment

tl/dr

query = User.select().where(User.username == 'reads-the-manual')
if query.exists():
    print('there are %s users who %s' (query.count(), 'read the manual'))

All 3 comments

I was searching for the same thing (I don't usually RTFM right away either). Just to let you know that your links don't take you to the right place on the page as I assume the # is supposed to do.

tl/dr

query = User.select().where(User.username == 'reads-the-manual')
if query.exists():
    print('there are %s users who %s' (query.count(), 'read the manual'))
Was this page helpful?
0 / 5 - 0 ratings

Related issues

christianmalek picture christianmalek  路  4Comments

lucasrc picture lucasrc  路  5Comments

alexlatchford picture alexlatchford  路  4Comments

mikemill picture mikemill  路  3Comments

ghost picture ghost  路  5Comments