0
我試圖執行的查詢是this one。我已經粘貼下面它:試圖在SQLAlchemy中執行「高級」查詢,但我被卡住了
SELECT p.id, p.title, p.time_submitted, SUM(v.score) as num_votes
FROM posts p, votes v
WHERE v.postid = p.id
GROUP BY p.id
ORDER BY
(SUM(v.score) - 1)/POW(TIMESTAMPDIFF(HOUR,p.time_submitted,NOW()) + INTERVAL 2 HOUR, 1.8) DESC
LIMIT 100
我要訴諸使用connection.execute
手動運行該SQL不使用ORM,但後來意識到它會在開發模式(金字塔)失敗,因爲SQLite不支持使用的功能。
我怎麼會去與ORM執行呢?
DBSession().query(Posts).join(Posts.id, Votes.post_id).group_by(Posts.id).order_by(...)
我不知道如何進一步>。 <