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.
Are there any configuration possibilities concerning the delete() -method of SQLAlchemy’s Sessions ? I’d
Share
Create your own session class inheriting from
Sessionand override thedelete()method with your own logic (for those classes that requirelogical delete), falling back to the default implemetation for the other objects. If you use sessionmaker or similar factory, you can provide your class in theclass_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.