Perfect - thanks Mike!
As I'm using 0.4 (sorry, neglected to mention that) I've gone for the
table.update(...).execute() option and it works a treat.
On Jan 25, 12:25 am, Michael Bayer mike...@zzzcomputing.com wrote:
the update() method on Query accomplishes this. Make sure you read
the docstring for it which describes some various behaviors you'll
want to be aware of.
alternatively, any SQL expression, like table.update(), UPDATE
table can be issued within the ORM's transaction using
session.execute().
On Jan 24, 2009, at 7:14 PM, James wrote:
Hi,
Is there a way to update a large number of objects without looping
through each one, using SA's ORM?
E.g.
I want to achieve the following:
for o in session.query(MyClass).filter_by(prop='some value'):
o.prop = 'new value'
session.update(o)
Without fetching and saving each object from the database. I.e.
something which would produce SQL like this:
UPDATE `my_class` SET `prop`='new value' WHERE `prop` = 'some value'
If not, am I safe mixing and matching ORM operations with SQL
operations like:
u = my_classes.update(my_class.c.prop=='some value'), values=
{'prop':'new value'})?
Thanks!
James
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To post to this group, send email to sqlalchemy@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
-~--~~~~--~~--~--~---