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) #
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
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()`
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