How to make a subquery in sqlalchemy
<pre><code>SELECT *
FROM Residents
WHERE apartment_id IN (SELECT ID
                       FROM Apartments
                       WHERE postcode = 2000)
</code></pre>

<p>I'm using sqlalchemy and am trying to execute the above query. I haven't been able to execute it as raw  SQL using <code>db.engine.execute(sql)</code> since it complains that my relations doesn't exist... But I succesfully query my database using this format: <code>session.Query(Residents).filter_by(???)</code>.
I cant not figure out how to build my wanted query with this format, though.</p>