Skip to main content

Declarative query builder for SQLAlchemy

Project description

Latest version Documentation Status Travis-CI Code coverage

filteralchemy is a declarative query builder for SQLAlchemy. filteralchemy uses marshmallow-sqlalchemy to auto-generate filter fields and webargs to parse field parameters from the request. Use it to filter data with minimal boilerplate.

For Django users: the design of filteralchemy is strongly inspired by django-filter.

Install

pip install filteralchemy

Quickstart

import flask
from models import Album, session
from webargs.flaskparser import parser

from filteralchemy import FilterSet
from filteralchemy.operators import Equal, Less, Greater

class AlbumFilterSet(FilterSet):
    class Meta:
        model = Album
        query = session.query(Album)
        operators = (Equal, Less, Greater)
        parser = parser

app = flask.Flask(__name__)

@app.route('/albums')
def get_albums():
    query = AlbumFilterSet().filter()
    return flask.jsonify(query.all())
http :5000/albums artist==Queen genre==rock sales__gt==1000000

Project details


Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for filteralchemy, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size filteralchemy-0.1.0-py2.py3-none-any.whl (8.5 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size filteralchemy-0.1.0.tar.gz (5.6 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page