Execute flask-SQLAlchemy subquery
<p>I want to execute the following subquery in flask-SQLAlchemy but don't know how:</p>

<pre><code>SELECT * 
FROM (
     SELECT * 
     FROM  `articles` 
     WHERE publisher_id = "bild"
     ORDER BY date_time DESC 
     LIMIT 10
) AS t
ORDER BY RAND( ) 
LIMIT 2
</code></pre>

<p>I know I can build the query as:</p>

<pre><code>subq = Article.query.filter(Article.publisher_id =='bild').order_by(Article.date_time.desc()).limit(10).subquery()
qry = subq.select().order_by(func.rand()).limit(2)
</code></pre>

<p>However I don't know how to execute it in the same fashion as I would execute e.g.</p>

<pre><code>articles = Article.query.filter(Article.publisher_id =='bild').all()
</code></pre>

<p>i.e. to get all the Article objects. What I can do is call</p>

<pre><code>db.session.execute(qry).fetchall()
</code></pre>

<p>but this only gives me a list with actual row values instead of the objects on which I could for example call another function (like <code>article.to_json()</code>).</p>

<p>Any ideas? <code>qry</code> is a <code>sqlalchemy.sql.selectable.Select</code> object and <code>db.session.execute(qry)</code> a <code>sqlalchemy.engine.result.ResultProxy</code> while <code>Article.query</code>, on which I could call <code>all()</code>, is a <code>flask_sqlalchemy.BaseQuery</code>. Thanks!!</p>