On Oct 22, 2010, at 5:30 AM, Aydın ŞEN wrote: > > 2010/10/22 Michael Bayer <mike...@zzzcomputing.com> > > query has an update(): > > query(MyTable).filter(MyTable.id==5).update(myDict) > > otherwise: > > for k in myDict: > setattr(some_object, k, myDict[k]) > Session.commit() > > > yeap, update() is doing what i want. > > > same techniques, update myDict with {'categories':[x, y, z]} > > Nope, adding 'categories' in myDict doesnt update relation. There is nothing > about relations' update in sql statement which generated by update(). >
more specifically, query(Category).filter(...).update(some_dict) for the "update" version - the filter criterion would be used to target each set of rows you'd like to UPDATE. The relationship() construct is not used with query.update(). If you want to emit UPDATE statements en-masse, you can also look into using the SQL expression language, instead of the ORM - examples of UPDATE are at : http://www.sqlalchemy.org/docs/core/tutorial.html#inserts-and-updates -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.