[sqlalchemy] Re: Selecting an ORM from self JOINs and/or from a query with subqueries

2009-06-19 Thread Michael Bayer
Alexander Kotelnikov wrote: Assuming I have a table CREATE TABLE seq (i int auto_increment primary key, used bool default false); And want to query an mapped object from it which corresponds a query SELECT i,used FROM seq WHERE NOT used AND i+1 IN (SELECT i FROM seq WHERE AND used) or

[sqlalchemy] Re: Selecting an ORM from self JOINs and/or from a query with subqueries

2009-06-19 Thread sacha
Michael, do you mean, that subqueries could not be wrapped into sqlalchemy? what should be the arguments to join() I failed to figure out? how do I reference different instances of seq in fileter() after? Thanks, A On Jun 19, 7:43 am, Michael Bayer mike...@zzzcomputing.com wrote: you can map

[sqlalchemy] Re: Selecting an ORM from self JOINs and/or from a query with subqueries

2009-06-19 Thread Michael Bayer
sacha wrote: Michael, do you mean, that subqueries could not be wrapped into sqlalchemy? you talked about mapping to a select statement. mapping means this: m = mapper(MyClass, someselectable) mapping like the above is usually done against individual tables, and usually once per class per

[sqlalchemy] Re: Selecting an ORM from self JOINs and/or from a query with subqueries

2009-06-19 Thread sacha
I really want to get a clear vision. So, I have a table x and mapped class X. I can use query(X) for simple queries, can I query(X) for structured ones like SELECT * FROM x WHERE x.a IN (SELECT ) ? Same about multi-cartesian product can I use query(X).join() for SELECT * FROM x JOIN x

[sqlalchemy] Re: Selecting an ORM from self JOINs and/or from a query with subqueries

2009-06-19 Thread sacha
I meant SELECT x.* FROM x JOIN x AS x1 JOIN x AS x2 ... WHERE On Jun 19, 1:55 pm, sacha sa...@myxomop.com wrote: Same about multi-cartesian product can I use query(X).join() for SELECT * FROM x JOIN x JOIN x . ? --~--~-~--~~~---~--~~ You received

[sqlalchemy] Re: Selecting an ORM from self JOINs and/or from a query with subqueries

2009-06-19 Thread Michael Bayer
sacha wrote: I really want to get a clear vision. So, I have a table x and mapped class X. I can use query(X) for simple queries, can I query(X) for structured ones like SELECT * FROM x WHERE x.a IN (SELECT ) sel = session.query(X.a).filter(X.b=='foo')