I've been looking for a way to limit and offset custom sql statement.
I can't use query from orm or select with limit and offset methods.
I simply get sql string which I execute.
q = text(sqlstr)
res = session.execute(q).fetchall()
I want to have some paging of the result. I've come out with sort of a
solution using fetchmany() twice. First to skipp rows I don't need
(implementation of offset) then second time (implementation of limit)
which result I use.
lim = url_params.get('limit')
off = url_params.get('offset')
if off:
q.fetchmany(off)
if lim:
result = q.fetchmany(lim)
else:
result = q.fetchall()
I know it's very wasteful. Maybe you could give me a hint on how to
achieve limit and offset.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.