Skip to main content

Boolean search expression parser for SQLAlchemy

Project description

SQLAlchemy-boolean-search translates a boolean search expression such as:

field1=*something* and not (field2==1 or field3<=10.0)

into its corresponding SQLAlchemy filter.

Install

pip install sqlalchemy-boolean-search

Usage example

from sqlalchemy_boolean_search import parse_boolean_search

# DataModel defined elsewhere (with field1, field2 and field3)
from app.models import DataModel

# Parse boolean search into a parsed expression
boolean_search = 'field1=*something* and not (field2==1 or field3<=10.0)'
parsed_expression = parse_boolean_search(boolean_search)

# Retrieve records using a filter generated by the parsed expression
records = DataModel.query.filter(parse_expression.filter(DataModel))

Documentation

SQLAlchemy-boolean-search Documentation

Project details


Download files

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

Source Distribution

SQLAlchemy-boolean-search-0.1.0.tar.gz (4.2 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page