[sqlalchemy] Re: How do I copy an object and save to database?

2017-12-20 Thread Tom Tanner
Thank you On Wednesday, December 20, 2017 at 8:37:57 AM UTC-5, Lele Gaifax wrote: > > Tom Tanner > writes: > > > Lele, could you write the code showing how that would look? Thanks. > > Extending Mike's answer: > > from sqlalchemy.orm import make_transient > make_transient(someObj) #

[sqlalchemy] Re: How do I copy an object and save to database?

2017-12-20 Thread Lele Gaifax
Tom Tanner writes: > Lele, could you write the code showing how that would look? Thanks. Extending Mike's answer: from sqlalchemy.orm import make_transient make_transient(someObj) # someObj is no longer in the session del someObj.id# assume this is the primary key

[sqlalchemy] Re: How do I copy an object and save to database?

2017-12-20 Thread Tom Tanner
Lele, could you write the code showing how that would look? Thanks. On Wednesday, December 20, 2017 at 2:22:49 AM UTC-5, Lele Gaifax wrote: > > Tom Tanner > writes: > > > Thanks, I used the first method. Follow up question: How do I get the > new > > primary key after running `session.commit()`

[sqlalchemy] Re: How do I copy an object and save to database?

2017-12-19 Thread Lele Gaifax
Tom Tanner writes: > Thanks, I used the first method. Follow up question: How do I get the new > primary key after running `session.commit()`? After a commit SA should have (re)populated the "id" field (or whatever it's PK field is named) of the cloned object. ciao, lele. -- nickname: Lele Ga