Paranoid3
This fork has been updated to work with SQLAlchemy 3.
Brings transparent soft delete to SQLAlchemy ORM. This branch has been modified to add the with_deleted() and restore() methods for interacting with soft-deleted resources.
Installation
pip install sqla-paranoid3
Usage
from paranoid.models import (
Model,
Query,
Session,
)
class User(Model):
__tablename__ = 'user'
__softdelete__ = True
id = Column(Integer, primary_key=True)
name = Column(String)
engine = create_engine('sqlite://')
session = sessionmaker(engine, class_=Session, query_cls=Query)()
session.query(User)
# retrieve a user that has not been deleted (assuming ID is 1)
user = User.query.get(1)
# soft delete the user
user.delete()
# query for a soft deleted user
user = User.query.with_deleted().get(1)
# or
user = User.query.with_deleted().filter_by(id=1).first()
# restore the user (undo soft delete)
user.restore()
# save the changes
session.add(user)
session.commit()
# hard delete the user
session.delete(user, hard=True)
session.commit()
Flask
Paranoid3 comes with a ready to use Flask extension built on top of Flask-SQLAlchemy:
from paranoid.flask import SQLAlchemy
db = SQLAlchemy(app)
# or you can use the factory style of initialisation
db = SQLAlchemy()
db.init_app(app)
Model = db.Model
class User(Model):
__softdelete__ = True
id = Column(Integer, primary_key=True)
name = Column(String)
User.query
Metadata
Release files for sqla-paranoid3 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sqla_paranoid3-0.1.4.tar.gz | 5.1 kB | Without provenance | Details for sqla_paranoid3-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sqla_paranoid3-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for sqla_paranoid3-0.1.4-py3-none-any.whl |
Total release size: 10.8 kB
Release files / sqla_paranoid3-0.1.4.tar.gz
| Download URL | sqla_paranoid3-0.1.4.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
354bc6a3d9c4af60b091c783e986784bd870c1f64c5dcc0679a661304e72ccce
|
|
BLAKE2b-256 checksum How to use checksums |
aba7b4e5eab424d6fc1e75466a7c6a03689c4a9cc0b87910444b039aa69fed8b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Release files / sqla_paranoid3-0.1.4-py3-none-any.whl
| Download URL | sqla_paranoid3-0.1.4-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
14b979fdcf5d6e683df4148cca59da377a8b13e28785c069fef2e755cf93ef05
|
|
BLAKE2b-256 checksum How to use checksums |
f487d6eae9dce00dd9517e9aa2c1b3fbc606ee8016f319a6c84ca71bdcc0037b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Security for sqla-paranoid3 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.