Are there any configuration possibilities concerning the delete()
-method of SQLAlchemy's Sessions
? I'd like to have the corresponding objects marked with a deleted flag in the database and not removed from it. Is there a way to achieve this? The aim is to build a database without destructive updates without losing the advantages of SQLAlchemy's cascading features.
Create your own session class inheriting from Session
and override the delete()
method with your own logic (for those classes that require logical delete
), falling back to the default implemetation for the other objects. If you use sessionmaker or similar factory, you can provide your class in the class_
parameter as well.
Hopefully, this answers your question. But, having said/written that, there is SOOO MUCH MORE to the logical deletion especially in term of Referential Integrity
, that one can write a series of articles on that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With