query has both bulk delete and update methods http://www.sqlalchemy.org/docs/05/reference/orm/query.html#the-query-object
count = session.query(Person).filter(... whatever criteria ...).delete(synchronize_session=False) On Fri, Feb 20, 2009 at 5:22 AM, Ids <idsvandermo...@gmail.com> wrote: > > Hello, > > I'm using the declarative extension and was wondering (after searching > the docs) how to elegantly delete multiple objects at once, preferably > without loading them in first. Suppose you've got a mapped class like > this: > class Person(Base): > __tablename__ = 'persons' > stamp = sa.Column(sa.DateTime) > ... > > Now you could delete multiple objects like this (I think): > Person.__table__.delete().where(stamp < somedate) > > or like this with loading all objects: > persons = session.query(Person).filter(Person.stamp < somedate) > for person in persons: > session.delete(person) > > Is there something like session.delete(Person).filter(Person.stamp < > somedate) ?? i.e. something similar to the session.query construct but > instead of selecting performing a delete? > > Regards, > Ids > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---