Re: [sqlalchemy] ORM: walk() related objects

2015-09-10 Thread Mike Bayer
On 9/10/15 8:48 AM, Pavel S wrote: Let's say, I have declarative classes A, B, C, D. A is the parent B has FK to A C has FK to B, D has FK to C etc... I'd like to implement _generic method_ walk(obj) which will recursively yield dependent/related objects of obj (which is instance of A).

Re: [sqlalchemy] ORM: walk() related objects

2015-09-10 Thread Pavel S
Hi Michael, this is amazing, thanks!!! On Thursday, September 10, 2015 at 3:35:39 PM UTC+2, Michael Bayer wrote: > > > > On 9/10/15 8:48 AM, Pavel S wrote: > > Let's say, I have declarative classes A, B, C, D. > > A is the parent > B has FK to A > C has FK to B, > D has FK to C etc... > > I'd

[sqlalchemy] ORM: walk() related objects

2015-09-10 Thread Pavel S
Let's say, I have declarative classes A, B, C, D. A is the parent B has FK to A C has FK to B, D has FK to C etc... I'd like to implement *generic method* walk(obj) which will recursively yield dependent/related objects of obj (which is instance of A). I know that there is introspection

Re: [sqlalchemy] ORM: walk() related objects

2015-09-10 Thread Ladislav Lenart
On 10.9.2015 16:30, Mike Bayer wrote: > On 9/10/15 10:26 AM, Mike Bayer wrote: >> >> >> On 9/10/15 10:13 AM, Ladislav Lenart wrote: >>> Hello. >>> >>> Just a really, really tiny and pedantic correction... The stack >>> variable in the >>> code is in fact a queue. This could potentially surprise

Re: [sqlalchemy] alembic.op.create_index algorithm=inplace lock=none

2015-09-10 Thread murray . wasley
thanks Michael, exactly the path I took ... cheers On Tuesday, September 8, 2015 at 12:04:58 PM UTC-4, Michael Bayer wrote: > > > > On 9/8/15 9:32 AM, murray...@lightspeedretail.com wrote: > > Hi there, > > Is there any way I can set additional params on alembic.op.create_index. > We are using

Re: [sqlalchemy] ORM: walk() related objects

2015-09-10 Thread Mike Bayer
On 9/10/15 9:35 AM, Mike Bayer wrote: On 9/10/15 8:48 AM, Pavel S wrote: Let's say, I have declarative classes A, B, C, D. A is the parent B has FK to A C has FK to B, D has FK to C etc... I'd like to implement _generic method_ walk(obj) which will recursively yield dependent/related

Re: [sqlalchemy] ORM: walk() related objects

2015-09-10 Thread Mike Bayer
On 9/10/15 10:26 AM, Mike Bayer wrote: On 9/10/15 10:13 AM, Ladislav Lenart wrote: Hello. Just a really, really tiny and pedantic correction... The stack variable in the code is in fact a queue. This could potentially surprise some users / readers. To fix, please do one of the

Re: [sqlalchemy] ORM: walk() related objects

2015-09-10 Thread Ladislav Lenart
Hello. Just a really, really tiny and pedantic correction... The stack variable in the code is in fact a queue. This could potentially surprise some users / readers. To fix, please do one of the following: * Rename stack local var to queue. * Use stack.pop() to pop the last element from the

Re: [sqlalchemy] ORM: walk() related objects

2015-09-10 Thread Pavel S
In the meanwhile, I've implemented similar: def walk(obj, level=0, memo=None): memo = memo or set() if obj not in memo: yield level, obj memo.add(obj) insp = inspect(obj) for relationship in insp.mapper.relationships:

Re: [sqlalchemy] ORM: walk() related objects

2015-09-10 Thread Mike Bayer
On 9/10/15 10:13 AM, Ladislav Lenart wrote: Hello. Just a really, really tiny and pedantic correction... The stack variable in the code is in fact a queue. This could potentially surprise some users / readers. To fix, please do one of the following: * Rename stack local var to queue. * Use

[sqlalchemy] Re: how to tell which tables already joined in a query statement (or best way to dynamically build a query?)

2015-09-10 Thread Brian Cherinka
Hi Michael, Thanks for your response. It helped a lot. I ended up going with the quick and dirty query.from_obj[0] method you described. That was faster to implement and served my purposes exactly. Cheers, Brian > > -- You received this message because you are subscribed to the Google