Re: [sqlalchemy] Raising on usage of attribute in SQL queries

2017-08-18 Thread Neena Parikh
Thanks all for the prompt and thorough responses! use Column subclass (class DontUseCol(Column)) then use @compiles to raise > any time this column is accessed in a SQL context We chose to follow this approach. It is a lightweight solution that works well for all of the outlined use cases,

Re: [sqlalchemy] How do I get an object and update multiple fields in sqlalchemy

2017-08-18 Thread Simon King
No, but you can trivially write your own function to do it: def updateobj(obj, data): for key, value in data.items(): setattr(obj, key, value) Simon On Fri, Aug 18, 2017 at 3:14 PM, pravin battula wrote: > The solution which you gave will work but I have a

Re: [sqlalchemy] How do I get an object and update multiple fields in sqlalchemy

2017-08-18 Thread pravin battula
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

Re: [sqlalchemy] How do I get an object and update multiple fields in sqlalchemy

2017-08-18 Thread Simon King
On Fri, Aug 18, 2017 at 2:41 PM, pravin battula 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

[sqlalchemy] How do I get an object and update multiple fields in sqlalchemy

2017-08-18 Thread pravin battula
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