On Aug 20, 2009, at 12:30 PM, thatsanicehatyouh...@mac.com wrote:

>
>
> On 19 Aug 2009, at 18:32, Mike Conley wrote:
>
>> The delete method of query supports bulk deletes.
>> In your case it might be something like
>>
>> session.query(Users).filter(User.officeid==office.id).delete()
>>
>> Any query can be used; there are probably more elegant ways to take
>> advantage of the relation 'users' also.
>>
>> Make sure you read the documentation for Query.delete() to
>> understand the impact of the 'synchronize_session' keyword
>
>
> Thanks for the tip - I wasn't aware of query's delete method. Still,
> it strikes me as a bit inefficient to look up objects that I already
> have at hand. (Even if the engine has to look them up due to lazy
> loading, *I* have them at hand.) Ah well.

why not query.filter(MyObject.id.in_(x.id for x in  
myobjects)).delete() ?  then no lookup.


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to