Thank you Sergey. On Saturday, June 4, 2022 at 7:08:25 AM UTC-4 Sergey V. wrote:
> An alternative would be > > session.query(User).filter(User.id_ == id).count() > > On Saturday, June 4, 2022 at 4:45:49 AM UTC+10 jason....@stormfish-sci.com > wrote: > >> 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 sqlalchemy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/15c3af94-ec76-4600-bca7-c6ba6cc09a38n%40googlegroups.com.