you probably want to use passive_deletes=True as well so that collections aren't loaded in for unnecessary, individual DELETEs:
http://www.sqlalchemy.org/docs/orm/collections.html#using-passive-deletes On Dec 10, 2010, at 7:27 PM, Matin Tamizi wrote: > Note to self: read docs better. > > I had to add a cascade='delete' in the backref. I tried this the first time, > but put it in the relationship instead of the backref. > class Post(Base): > __tablename__ = 'posts' > id = Column(Integer, primary_key=True) > title = Column(String(255), nullable=False) > body = Column(Text, nullable=False) > user_id = Column(Integer, ForeignKey(User.id, ondelete='CASCADE'), > nullable=False) > user = relationship(User, backref=backref('posts', cascade='delete')) > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
