q = session.query(myClass) for attr, value in web_dict.items(): q = q.filter(getattr(myClass, attr).like("%%%s%%" % value))