Is there a way to avoid iterating through a query in sqlalchemy to do a simple update? As is seems this method is over processing for something that the DB should handle.
E.g. could this be avoided?
items = db_session.query(Item).filter_by(category_id=category.id).all()
for item in items:
item.category_id = new_category_id
db_session.add(item)
db_session.commit()
I'm looking for something like:
items = db_session.query(Item).filter_by(category_id=category.id).all()
items.update(category_id=new_category_id)
db_session.commit()
Thanks for any help on this.