I'm answering my own question.
The 'WindowedRangeQuery' on the SQLAlchemy wiki page (link provided by @Yaroslav Admin) would be ideal, but apparently MySql lacks 'window functions'. The 'Non Window Function Version' method mentioned on the wiki page, scales better, but makes too many assumptions about the data.
This solution works, but it becomes slower for each page due to the added offset:
def get_all_trades(self):
pagesize = 1000000
row_count = self.session.query(Trade).count()
offset = 0
while offset < row_count:
query = self.session.query(Trade). \
order_by(Trade.time). \
slice(offset, offset+pagesize). \
limit(pagesize)
offset += pagesize
for d in query:
yield d
I'm not really happy with the solution. Maybe I should switch to Postgresql to get those window functions going.