On Fri, Aug 18, 2017 at 2:41 PM, pravin battula
<pravin.batt...@gmail.com> wrote:
> Hi,
>
> I'm getting an instance of a model using a primary key like below.
> product_live_time = session.query(ProductLiveTime).get(product_id)
>
> Now, i want to update few columns using the same instance product_live_time,
> how can i do it without doing filter again like below i.e
> session.query(ProductLiveTime).filter(ProductLiveTime.product_id ==
> product_id).update(data).
> is there any other better way of doing it.
>

Maybe I'm misunderstanding the question, but:

product_live_item.attr1 = value1
product_live_item.attr2 = value2
session.flush()

Is that what you meant?

Simon

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to