On Aug 12, 2011, at 11:52 AM, 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 > > HTH > > NiL
You can also use the class's __dict__ member: field_attr = Klass.__dict__['field'] It really amazes me how Pythonic SQLAlchemy makes database access. Mark -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.