Is it possible to use an active mapper class to do something like the
following example in the sqlalchemy documentation:
statement = users.select()
if id is not None:
statement.append_whereclause(users.c.user_id==id)
if name is not None:
statement.append_whereclause(users.c.user_name==name)
if street is not None:
# append_whereclause joins "WHERE" conditions together with AND
statement.append_whereclause(users.c.user_id==addresses.c.user_id)
statement.append_whereclause(addresses.c.street==street)
if keywords is not None:
statement.append_from(
users.join(userkeywords,
users.c.user_id==userkeywords.c.user_id).join(
keywords,
userkeywords.c.keyword_id==keywords.c.keyword_id))
statement.append_whereclause(keywords.c.name.in_(keywords))
# to avoid multiple repeats, set query to be DISTINCT:
statement.distinct=True
return statement.execute()
Thanks,
chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" 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/turbogears
-~----------~----~----~----~------~----~------~--~---