DEV Community

Discussion on: SQLAlchemy Cascading Deletes

Collapse
 
lefnire profile image
Tyler Renelle

So just the two, right?

artist_id = Column(Integer, ForeignKey("artist.id", ondelete="cascade"))
songs = relationship("Song", cascade="all, delete", passive_deletes=True)
Enter fullscreen mode Exit fullscreen mode

with passive_deletes=True set, do you need cascade="all, delete"? It sounds like passive_deletes says "skip doing what I do, defer to DB", so my impression is we can remove cascades?