two general strategies are to use the SelectResults plugin:

        from sqlalchemy.ext.selectresults import SelectResultsExt
        mapper(Class, table, extension=SelectResultsExt())

        result = query.select_by(name='john').order_by(table.c.foo).limit(10)

or play with the join_by() function:

        result = query.select(query.join_by(name='john'),  
order_by=table.c.foo, limit=10)


On Jul 20, 2006, at 9:40 PM, Martin Stein wrote:

> Hi everybody,
>
> I was wondering if it's possible to do a mapper query like this:
>
> result = query.select_by(name='john')
>
> including order_by, limit, or offset specifications?
>
> So far, I have only been able to do this with:
>
> result = query.select(users_table.c.user_name=='john', limit=10)
>
> for example. However, I would like to avoid this syntax, since I think
> (with regard to encapsulation), it would be better if the query  
> does not
> need to refer to the table structure itself. I mean, my query knows  
> that
>
> name='john'
> , but it should not need to know that
>
> users_table.c.user_name=='john'
>
> since that is what the OR-mapper is responsible for. Using the  
> latter way, any
> changes in the database itself (for example renaming the user_name  
> column) lead to changes
> in the query as well (plus changing the mapper, maybe). I would  
> like to avoid that.
> What do you think?
>
> Thanks, Martin
>
> P.S.: Sorry, if this is a double post. My email provider seems to  
> be having some problems.
> _____________________________________________________________________
> Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
> http://smartsurfer.web.de/?mc=100071&distributionid=000000000071
>
>
> ---------------------------------------------------------------------- 
> ---
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to  
> share your
> opinions on IT & business topics through brief surveys -- and earn  
> cash
> http://www.techsay.com/default.php? 
> page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Sqlalchemy-users mailing list
> Sqlalchemy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to