Registry / database / sqlalchemy-easy-softdelete

sqlalchemy-easy-softdelete

JSON →
library0.9.0pypypiunverified

Provides a mixin and utilities to add soft-deletion (deleted_at column) to SQLAlchemy ORM models. Version 0.9.0 supports SQLAlchemy 2.x and requires Python >=3.10. Actively maintained.

pip install sqlalchemy-easy-softdelete
INSTALL
IMPORT
SIG · SQLALCHEMY-EASY-SO
S
sqlalchemy-easy-softdelete
databasepythonv0.9.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SoftDeleteMixin
from sqlalchemy_easy_softdelete import SoftDeleteMixin
from sqlalchemy_easy_softdelete.mixin import SoftDeleteMixin

Defines a model with soft-delete support. The delete() method on the session performs a soft delete by setting deleted_at timestamp.

from sqlalchemy import create_engine, Column, Integer, String from sqlalchemy.orm import DeclarativeBase from sqlalchemy_easy_softdelete.mixin import SoftDeleteMixin engine = create_engine('sqlite:///:memory:') class Base(DeclarativeBase): pass class User(SoftDeleteMixin, Base): __tablename__ = 'users' id = Column(Integer, primary_key=True) name = Column(String) Base.metadata.create_all(engine) from sqlalchemy.orm import Session with Session(engine) as session: user = User(name='Alice') session.add(user) session.commit() session.delete(user) # This will soft-delete session.commit()
Debug
Known issues
gotchaThe library overrides session.delete() to set deleted_at instead of hard deleting. This can be surprising if you expect actual deletion; hard deletion must be done with session.execute(delete(...)).
fix
Use session.execute() with a DELETE statement for hard deletes.
affects: >=0.1.0
deprecatedVersions before 0.7.0 used a different mixin location (from sqlalchemy_easy_softdelete import SoftDeleteMixin). That import path no longer works.
fix
Update import to from sqlalchemy_easy_softdelete.mixin import SoftDeleteMixin.
affects: <0.7.0
gotchaThe library automatically filters out soft-deleted records when querying. To include them, you must use with_deleted() method on the query.
fix
Use query = session.query(User).with_deleted() to include soft-deleted rows.
affects: >=0.1.0
Upgrade
Version history
0.9.0latest on PyPI · released Jan 26, 2026
Audit
Dependencies
sqlalchemyrequiredRequired; the library integrates with SQLAlchemy ORM.
Agent activity
14 hits · last 30 days
node
12
Meta
1
OpenAI (training)
1
Resources