Wickert, can you give me an example ? I'm a little confused by this
posts of yours. RVince

On Aug 12, 12:20 pm, Wichert Akkerman <[email protected]> wrote:
> On 08/12/2011 05:52 PM, NiL wrote:
>
>
>
> > say you want to filter on the 'field' (field would be a string
> > representing the name of the field) on objects of class == Klass
>
> > field_attr = getattr(Klass, field)
>
> >  would give you the instrumented attribute
>
> > then
>
> > Session.query(Klass).filter(field_attr == searchString)
>
> > or
>
> > Session.query(Klass).filter(field_attr.endswith(searchString))
>
> > would run
>
> Alternatively if you are only interested in equality you can skip the
> getattr and use filter_by in combination with python's keyword argument
> handling:
>
>      Session.query(klass).filter_by(**{field: value})
>
> Wichert.

-- 
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.

Reply via email to