[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.

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

2017-12-19 Thread Tom Tanner
Thanks, I used the first method. Follow up question: How do I get the new primary key after running `session.commit()`? On Tuesday, December 19, 2017 at 11:29:34 AM UTC-5, Mike Bayer wrote: > > On Tue, Dec 19, 2017 at 3:02 AM, Tom Tanner > wrote: > > I'm using

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

2017-12-19 Thread Mike Bayer
On Tue, Dec 19, 2017 at 3:02 AM, Tom Tanner wrote: > I'm using SQLAlchemy with the Python library Flask. > > How do I query an object from a database, make a copy of it, and save that > copy to the database? > > Example of querying an object. > someObj =

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

2017-12-19 Thread Tom Tanner
I'm using SQLAlchemy with the Python library Flask. How do I query an object from a database, make a copy of it, and save that copy to the database? Example of querying an object. someObj = db.session.query(SomeDataTable).filter_by(id=someID).first() I want to save a copy of `someObj` to the