Skip to main content

DSL for Django

Project description

django-dsl
==========

|Licence| |Version|

+------------------+--------------------+
| Status | Operating system |
+==================+====================+
| |Build_Status| | Linux x86\_64 |
+------------------+--------------------+

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
* `Regex`_ Searches: ~

* ~\W+ : Matches any character which is not a word character.
* Boolean Operators: AND OR NOT
* Grouping: ( )
* Date and number Searches (operators: < > <= >=) :

* key>2
* key<=2
* 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:

.. figure:: https://raw.githubusercontent.com/treussart/django-dsl/master/example-db.png
:alt: DB image

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
query = compile(request.GET['expression'])
cls.objects.filter(query)

.. _Regex: https://docs.python.org/3/library/re.html

.. |Build_Status| image:: https://travis-ci.org/treussart/django-dsl.svg?branch=master
:target: https://travis-ci.org/treussart/django-dsl

.. |Version| image:: https://img.shields.io/github/tag/treussart/django-dsl.svg
.. |Licence| image:: https://img.shields.io/github/license/treussart/django-dsl.svg


Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

File details

Details for the file django_domain_specific_language-1.2.3-py3-none-any.whl.

File metadata

File hashes

Hashes for django_domain_specific_language-1.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2068e54adeecd6479622da52913e1b24e765cae6242d20e842c03267d60156be
MD5 a4a47d58ff37f1ccbc4a2d6aa4d6ffbd
BLAKE2b-256 d6db8c3cdc01a64331a9b74e2533959475d0f8ffb548b7156431cfc8ec584265

See more details on using hashes here.

Supported by

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