sqlalchemy: what is the difference between declaring the cascade within the foreign key vs relation? -
What is the difference between declaring cascades within foreign key versus relationships? Category contact (base): __tablename__ = 'contacts' id = column (integer, primary_key = true) address = relationship ("address", backfruit = "contact") class address (base) ): __tablename__ = 'addresses' id = column (integer), primary_key = true) contact_id = column (integer, foreign key ('contact.id', onupdate = "CASCADE", ondelete = "CASCADE")))
versus
"Contact", cascade = "all, delete-orphans") class address (base): __tablename__ = 'AIDS' D = column (integer, primary_key = true) contact_id = column (integer, foreign '(contact.id'))
Foreign critical announcement, it seems that the cascade is applicable at the database level it happens. How does the relation work? Thanks!
You are right that the foreign key cassette is done at the database level probably inauspiciously approaches the Python level But, it is done. When parents are removed, then they are removed from the session, SQLAlchemy reads in relation and removes issues to all members, is processing any other cascade.
Also keep in mind that if you use database cascades, you also need to configure relationships to know about the fact.
Comments
Post a Comment