I believe I finally found a solution:

 select(func.count(User.id_)).where(User.id_ == id)

Thank you for taking the time to look.

On Friday, June 3, 2022 at 1:45:39 PM UTC-4 Jason Hoppes wrote:

> I would like to generate the following SQL using the ORM. I am testing for 
> no rows returning:
>
> select count(*) from users where id = 9999
>
> I found session.query(User.id_).count() however that does not have a 
> where clause. How would this be performed in the ORM with a where clause?
>
> Thanks,
>
> Jason
>

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/403c6775-1747-45ad-bb0e-cf712697e625n%40googlegroups.com.

Reply via email to