The query is much more complex than a simple select. And I'd rather maintain it in the form of a SQL query rather than "transliterated" into SQLAlchemy function-like construct.
Does DBSession.execute() accept SQL query as a string? I can't find an example that indicates this online. Thanks, Will On Jul 27, 10:29 am, "Diez B. Roggisch" <[email protected]> wrote: > On Monday 27 July 2009 17:15:39 shadowfox wrote: > > > Yes, I know I can run: > > > DBSession.query(SomeModel).from_statement(SOME_SQL_QUERY).all() > > > As long as SOME_SQL_QUERY returns columns within the table associated > > with SomeModel. > > > But a lot of times we need to run a more complex queries that returns > > results that spans multiple database tables. Back in TG1, using > > SQLObject, I can run such queries and get the correct results, but in > > SQLAlchemy, there seems to be no way to do this. > > Did you look into the sqlalchemy-docs? > > DBSession.execute(select([SomeModel.column, > SomeOtherModel.column]).join(SomeModel.some_other_model)) > > is one example. You can do of course a lot more. > > Diez --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---

