An open API service indexing awesome lists of open source software.

https://github.com/jeanphix/sqla-paranoid

Brings transparent soft delete to SQLAlchemy ORM.
https://github.com/jeanphix/sqla-paranoid

python softdelete sqlalchemy

Last synced: about 1 year ago
JSON representation

Brings transparent soft delete to SQLAlchemy ORM.

Awesome Lists containing this project

README

          

Paranoid
========

Brings transparent soft delete to SQLAlchemy ORM.

.. image:: https://travis-ci.org/jeanphix/sqla-paranoid.svg?branch=dev
:target: https://travis-ci.org/jeanphix/sqla-paranoid
:alt: Build Status

Installation
------------

.. code-block:: bash

pip install sqla-paranoid

Usage
-----

.. code-block:: python

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)

Flask
-----

Paranoid comes with a ready to use ``Flask`` extension built
on top of Flask-SQLAlchemy:

.. code-block:: python

from paranoid.flask import SQLAlchemy

db = SQLAlchemy(app)

Model = db.Model

class User(Model):
__softdelete__ = True

id = Column(Integer, primary_key=True)
name = Column(String)

User.query