Re: [sqlalchemy] How to commit objects with circular FK references?

2015-12-14 Thread Gerald Thibault
Thanks for the suggestions and examples. On Sunday, December 13, 2015 at 9:04:17 AM UTC-8, Michael Bayer wrote: > > > > On 12/12/2015 09:56 PM, Gerald Thibault wrote: > > I am loading data from json files, and then creating instances via > > ObjClass(**data), loading them into a session, and

Re: [sqlalchemy] How to commit objects with circular FK references?

2015-12-13 Thread Mike Bayer
On 12/12/2015 09:56 PM, Gerald Thibault wrote: > I am loading data from json files, and then creating instances via > ObjClass(**data), loading them into a session, and committing. I do not > see an easy way to go from having an integer foreign_key value to > populating the relationship with the

RE: [sqlalchemy] How to commit objects with circular FK references?

2015-12-12 Thread Gombas, Gabor
r 2015 02:49 > To: sqlalchemy@googlegroups.com > Subject: Re: [sqlalchemy] How to commit objects with circular FK references? > > > > On 12/11/2015 07:47 PM, Gerald Thibault wrote: > > Is there a way to perform a Metadata.create_all() but have it only > >

Re: [sqlalchemy] How to commit objects with circular FK references?

2015-12-12 Thread Mike Bayer
On 12/12/2015 06:31 PM, Gerald Thibault wrote: > I ended up with the following code to preprocess the session and collect > the problematic updates into a collection, which I then issue after the > initial flush. It looks really ugly, and I'm wondering if any of this > could be more easily

Re: [sqlalchemy] How to commit objects with circular FK references?

2015-12-12 Thread Gerald Thibault
I am loading data from json files, and then creating instances via ObjClass(**data), loading them into a session, and committing. I do not see an easy way to go from having an integer foreign_key value to populating the relationship with the corresponding model in order to have post_update

Re: [sqlalchemy] How to commit objects with circular FK references?

2015-12-12 Thread Gerald Thibault
I ended up with the following code to preprocess the session and collect the problematic updates into a collection, which I then issue after the initial flush. It looks really ugly, and I'm wondering if any of this could be more easily handled via a hook somewhere in SQLA? Particularly the

Re: [sqlalchemy] How to commit objects with circular FK references?

2015-12-11 Thread Mike Bayer
On 12/11/2015 05:25 PM, Gerald Thibault wrote: > I am basing my question off the code > at > http://docs.sqlalchemy.org/en/latest/orm/relationship_persistence.html#rows-that-point-to-themselves-mutually-dependent-rows, > with a few changes. > > I am trying to handle a situation very similar to

Re: [sqlalchemy] How to commit objects with circular FK references?

2015-12-11 Thread Gerald Thibault
Is there a way to perform a Metadata.create_all() but have it only create the tables, without any of the FKs? And then create the FKs in one go after the fixture data has been loaded into the DB? On Friday, December 11, 2015 at 3:38:16 PM UTC-8, Michael Bayer wrote: > > > > On 12/11/2015 05:25

Re: [sqlalchemy] How to commit objects with circular FK references?

2015-12-11 Thread Mike Bayer
On 12/11/2015 07:47 PM, Gerald Thibault wrote: > Is there a way to perform a Metadata.create_all() but have it only > create the tables, without any of the FKs? And then create the FKs in > one go after the fixture data has been loaded into the DB? first off, this is unnecessary because the DDL