{"id":28300,"library":"sqlalchemy-easy-softdelete","title":"SQLAlchemy Easy SoftDelete","description":"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.","status":"active","version":"0.9.0","language":"python","source_language":"en","source_url":"https://github.com/williamjacks/sqlalchemy-easy-softdelete","tags":["sqlalchemy","soft-delete","orm","mixin"],"install":[{"cmd":"pip install sqlalchemy-easy-softdelete","lang":"bash","label":"latest"}],"dependencies":[{"reason":"Required; the library integrates with SQLAlchemy ORM.","package":"sqlalchemy","optional":false}],"imports":[{"note":"SoftDeleteMixin is in the mixin submodule, not the package root.","wrong":"from sqlalchemy_easy_softdelete import SoftDeleteMixin","symbol":"SoftDeleteMixin","correct":"from sqlalchemy_easy_softdelete.mixin import SoftDeleteMixin"},{"note":"Base is also in the mixin submodule.","wrong":"from sqlalchemy_easy_softdelete import Base","symbol":"Base","correct":"from sqlalchemy_easy_softdelete.mixin import Base"}],"quickstart":{"code":"from sqlalchemy import create_engine, Column, Integer, String\nfrom sqlalchemy.orm import DeclarativeBase\nfrom sqlalchemy_easy_softdelete.mixin import SoftDeleteMixin\n\nengine = create_engine('sqlite:///:memory:')\n\nclass Base(DeclarativeBase):\n    pass\n\nclass User(SoftDeleteMixin, Base):\n    __tablename__ = 'users'\n    id = Column(Integer, primary_key=True)\n    name = Column(String)\n\nBase.metadata.create_all(engine)\n\nfrom sqlalchemy.orm import Session\nwith Session(engine) as session:\n    user = User(name='Alice')\n    session.add(user)\n    session.commit()\n    session.delete(user)  # This will soft-delete\n    session.commit()","lang":"python","description":"Defines a model with soft-delete support. The delete() method on the session performs a soft delete by setting deleted_at timestamp."},"warnings":[{"fix":"Use session.execute() with a DELETE statement for hard deletes.","message":"The 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(...)).","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Update import to from sqlalchemy_easy_softdelete.mixin import SoftDeleteMixin.","message":"Versions before 0.7.0 used a different mixin location (from sqlalchemy_easy_softdelete import SoftDeleteMixin). That import path no longer works.","severity":"deprecated","affected_versions":"<0.7.0"},{"fix":"Use query = session.query(User).with_deleted() to include soft-deleted rows.","message":"The library automatically filters out soft-deleted records when querying. To include them, you must use with_deleted() method on the query.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Use: from sqlalchemy_easy_softdelete.mixin import SoftDeleteMixin","cause":"SoftDeleteMixin is located in the mixin submodule, not the package root.","error":"ImportError: cannot import name 'SoftDeleteMixin' from 'sqlalchemy_easy_softdelete'"},{"fix":"Ensure Base uses DeclarativeBase from SQLAlchemy (or use the provided Base from the mixin module).","cause":"Mixing SoftDeleteMixin with a Base that uses a different metaclass (e.g., from Flask-SQLAlchemy).","error":"TypeError: metaclass conflict: the metaclass of a derived class must be a subclass of the metaclasses of all its bases"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}