Skip to main content

DSL for Django

Project description

django-dsl

Licence Version

Requirements

  • PLY
  • Django

Installation

pip install django-domain-specific-language

Usage

Allows you to search by specifying the name of the column of the database.

Characters allowed:

  • Key (column name) : A-Za-z0-9_.
  • Value : all except ')' '(' and white space.

Query Parser Syntax:

  • Wildcard Searches: *

    • *test : All that ends by test
    • test* : All that starts by test
    • *test* : All that contains test
    • \*test\* : All equal to *test*
    • \*test* : All that starts by *test
    • *test\* : All that ends by test*
  • Regex Searches: ~

    • ~\W+ : Matches any character which is not a word character.
    • \~test : Matches all equal to ~test.
  • Boolean Operators: AND OR NOT

  • Grouping: ( )

  • Date and number Searches (operators: < > <= >=) :

    • key>2 : All greater than 2
    • key<=2 : All less than or equal to 2
    • key>2018-05-04 : All greater than 2018-05-04
    • key<=2018-05-04 : All less than or equal to 2018-05-04
  • Date Range Searches (inclusive) (which correspond to SQL queries of BETWEEN):

    • key:2018-05-04_2018-05-05
  • Null Searches (which correspond to SQL queries of IS NULL and IS NOT NULL):

    • key:True
    • key:False

Example

Your database:

DB image

The possible researches:

  • Country:India AND Product:Ice-cream
  • Country:*a* AND NOT Product:~.*e$

In your code:

from django_dsl.run import compile_expr
query = compile_expr(request.GET['expression'])
cls.objects.filter(query)

Project details


Download files

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

Files for django-domain-specific-language, version 1.2.6
Filename, size File type Python version Upload date Hashes
Filename, size django_domain_specific_language-1.2.6-py3-none-any.whl (17.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size django-domain-specific-language-1.2.6.tar.gz (17.7 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page