The solution which you gave will work but I have a dict of keys to be updated with that get instance. Is there any specific way of updating something like product_live_time_instance.update(data_dict).
On Friday, 18 August 2017 19:21:12 UTC+5:30, Simon King wrote: > > On Fri, Aug 18, 2017 at 2:41 PM, pravin battula > <pravin....@gmail.com <javascript:>> 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.