Skip to content
Advertisement

How to do a where exists in nested query with SQLAlchemy?

I’m trying to do a WHERE EXISTS clause in SQLAlchemy. The SQL looks like this:

Is it possible to do this in SQLAlchemy without using raw SQL? I’ve tried this but it doesn’t seem to be returning the correct results:

Advertisement

Answer

Use sqlalchemy.orm.aliased() and exists():

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement