question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Checking record exist

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

13reactions
coleifercommented, Oct 25, 2018

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'))
3reactions
kadnancommented, Feb 14, 2021

Funny thing is that I had to google something similar after 4 years and I found my own opened issue 😆

Read more comments on GitHub >

github_iconTop Results From Across the Web

SQL: How to properly check if a record exists - Stack Overflow
It's better to use either of the following: -- Method 1. SELECT 1 FROM table_name WHERE unique_key = value; -- Method 2.
Read more >
How to check if a record exists in table in Sql Server
How to check if a record exists in table in Sql Server · EXAMPLE 1: Using EXISTS clause in the IF statement to...
Read more >
Best way to test if a row exists in a MySQL table - Tutorialspoint
To test whether a row exists in a MySQL table or not, use exists condition. The exists condition can be used with subquery....
Read more >
Solved: Check if record exist - Power Platform Community
Solved: Hey, I want to check if a record exists in a collection or in an sql db. I tried to use statements...
Read more >
How to Check if a Record Exists in a MySQL Database - W3docs
<?php $query = "SELECT * FROM products WHERE code = '$code'"; $result = mysql_query($query); if ($result) { if (mysql_num_rows($result) > 0) { echo...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found