On Mon, Apr 21, 2008 at 11:51 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> I have a question regarding join, I want to join two tables (I have > not defined any ManyToOne,.. relationship between them and I can't), > but as a result I want to get an tuple (preferably) with the 2 > correlated rows as objects in it or one of the objects (for example > the row from the first table). I tried to use something like > > First.table.join(Second.table, First.var == > Second.var).select().execute().fetchall() > > however this returns a list of tuples (First.id, First.var, ..., > Second.id, ...) > I tried also this > > First.query.filter(First.var == Second.var).all() I think what you are looking for is "select_from". See: http://www.sqlalchemy.org/docs/04/ormtutorial.html#datamapping_joins and http://www.sqlalchemy.org/docs/04/sqlalchemy_orm_query.html#docstrings_sqlalchemy.orm.query_Query You might also be interested in "add_entity", though I've never used it myself so I don't know for sure. > on the test database it's acceptable, the real tables will be quite > larger => JOIN would be faster ... How so? I might not be fully awake yet, but I'd expect any decent database will have the same performance for an inner join as for a where statement, at least when only two tables are involved... -- Gaƫtan de Menten http://openhex.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "SQLElixir" 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/sqlelixir?hl=en -~----------~----~----~----~------~----~------~--~---
