im not sure what youre trying to do that you cant just do with the offset and limit parameters.  are you trying to avoid creating a select object, and then the mapper creating a second one internally ?   you can send a full select object to the mapper:

s = select(Campaign.c)
s.limit = limit
s.offset = offset
total = s.count().scalar()
rows = mapper.select(s)

but that is not going to work with eager loading, since LIMIT and OFFSET work in a more complicated way in that case, like the docs mention...there might also be other difficulties with creating your own column clause.

if its the select's conditions that are so important, you can hold onto the WHERE condition separately and send that to your select() and mapper.select() method.  if you tell me what you really need to do that would help.


On Mar 22, 2006, at 4:43 PM, Qvx 3000 wrote:

Yes, I know about it. I'm currently using limit and offset up-front, just like I said at the end of my post. I was asking for a way to do it later - after I have constructed select. The only way I see is using plain select but I get tuples as a result.

On 3/22/06, Michael Bayer <[EMAIL PROTECTED]> wrote:
mapper.select() takes a limit and offset parameter:

http://www.sqlalchemy.org/docs/
adv_datamapping.myt#adv_datamapping_limits

also Ben Bangert I think has some widget hes using with Pylons that
does this same thing with SQLAlchemy in a configurable way.

On Mar 22, 2006, at 3:38 PM, Qvx 3000 wrote:

> I'm writing a paginator for my web app. I would like to somehow be
> able to construct select statement from inside my controller, and
> then later use that select to add limit and offset and to count
> total number of records. Currently I can do this:
>
> inside controller:
> s = select(Campaign.c)
>
> inside paginator:
> s.limit = limit
> s.offset = offset
> total = s.count().scalar()
> rows = s.execute().fetchall()
>
> But the thing is I want to do it with Class/mapper because I want
> my objects back not tuples. If I do Campaign.select() it is
> immediately executed and fetched.
>
> Currently I have paginator which I ask for limit and offset so I
> can explicitly specify it while selecting, but I would like to do
> it just like I descibed it a moment ago.
>
> Regards,
> Tvrtko



Reply via email to