lib-rql


Namelib-rql JSON
Version 2.0.0 PyPI version JSON
download
home_pagehttps://connect.cloudblue.com/community/api/rql/
SummaryPython RQL Filtering
upload_time2023-05-30 12:20:52
maintainer
docs_urlNone
authorCloudBlue LLC
requires_python>=3.8,<4
licenseApache-2.0
keywords rql filter
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python RQL


[![pyversions](https://img.shields.io/pypi/pyversions/lib-rql.svg)](https://pypi.org/project/lib-rql/)
[![PyPi Status](https://img.shields.io/pypi/v/lib-rql.svg)](https://pypi.org/project/lib-rql/)
[![PyPI status](https://img.shields.io/pypi/status/lib-rql.svg)](https://pypi.org/project/lib-rql/)
[![PyPI Downloads](https://img.shields.io/pypi/dm/lib-rql)](https://pypi.org/project/lib-rql/)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=lib-rql&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=lib-rql)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=lib-rql&metric=coverage)](https://sonarcloud.io/summary/new_code?id=lib-rql)



## Introduction

RQL (Resource query language) is designed for modern application development. It is built for the web, ready for NoSQL, and highly extensible with simple syntax.
This is a query language fast and convenient database interaction. RQL was designed for use in URLs to request object-style data structures.

[RQL Reference](https://connect.cloudblue.com/community/api/rql/)

## Install

`Python RQL` can be installed from [pypi.org](https://pypi.org/project/lib-rql/) using pip:

```
$ pip install lib-rql
```

## Documentation

[`Python RQL` documentation](https://lib-rql.readthedocs.io/en/latest/) is hosted on the _Read the Docs_ service.


## Projects using Python RQL

`Django RQL` is the Django app, that adds RQL filtering to your application.

Visit the [Django RQL](https://github.com/cloudblue/django-rql) project repository for more informations.


## Notes

Parsing is done with [Lark](https://github.com/lark-parser/lark) ([cheatsheet](https://lark-parser.readthedocs.io/en/latest/lark_cheatsheet.pdf)).
The current parsing algorithm is [LALR(1)](https://www.wikiwand.com/en/LALR_parser) with standard lexer.

0. Values with whitespaces or special characters, like ',' need to have "" or ''
1. Supported date format is ISO8601: 2019-02-12
2. Supported datetime format is ISO8601: 2019-02-12T10:02:00 / 2019-02-12T10:02Z / 2019-02-12T10:02:00+03:00


## Supported operators

1. Comparison (eq, ne, gt, ge, lt, le, like, ilike, search)
2. List (in, out)
3. Logical (and, or, not)
4. Constants (null(), empty())
5. Ordering (ordering)
6. Select (select)
7. Tuple (t)


## Examples

### Parsing a RQL query


```python
from py_rql import parse
from py_rql.exceptions import RQLFilterError

try:
    tree = parse('eq(key,value)')
except RQLFilterError:
    pass
```


### Filter a list of dictionaries

```python
from py_rql.constants import FilterTypes
from py_rql.filter_cls import FilterClass


class BookFilter(FilterClass):
    FILTERS = [
        {
            'filter': 'title',
        },
        {
            'filter': 'author.name',
        },
        {
            'filter': 'status',
        },
        {
            'filter': 'pages',
            'type': FilterTypes.INT,
        },
        {
            'filter': 'featured',
            'type': FilterTypes.BOOLEAN,
        },
        {
            'filter': 'publish_date',
            'type': FilterTypes.DATETIME,
        },
    ]

filters = BookFilter()

query = 'eq(title,Practical Modern JavaScript)'
results = list(filters.filter(query, DATA))

print(results)

query = 'or(eq(pages,472),lt(pages,400))'
results = list(filters.filter(query, DATA))

print(results)
```


## Development


1. Python 3.8+
0. Install dependencies `pip install poetry && poetry install`

## Testing

1. Python 3.8+
0. Install dependencies `pip install poetry && poetry install`

Check code style: `poetry run flake8`
Run tests: `poetry run pytest`

Tests reports are generated in `tests/reports`.
* `out.xml` - JUnit test results
* `coverage.xml` - Coverage xml results

To generate HTML coverage reports use:
`--cov-report html:tests/reports/cov_html`

## License

`Python RQL` is released under the [Apache License Version 2.0](https://www.apache.org/licenses/LICENSE-2.0).

            

Raw data

            {
    "_id": null,
    "home_page": "https://connect.cloudblue.com/community/api/rql/",
    "name": "lib-rql",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4",
    "maintainer_email": "",
    "keywords": "rql,filter",
    "author": "CloudBlue LLC",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/e1/04/d42cd16ace7f0d53f51c8e8b904cf27457dac6d42c5631d4ce1459e2d474/lib_rql-2.0.0.tar.gz",
    "platform": null,
    "description": "# Python RQL\n\n\n[![pyversions](https://img.shields.io/pypi/pyversions/lib-rql.svg)](https://pypi.org/project/lib-rql/)\n[![PyPi Status](https://img.shields.io/pypi/v/lib-rql.svg)](https://pypi.org/project/lib-rql/)\n[![PyPI status](https://img.shields.io/pypi/status/lib-rql.svg)](https://pypi.org/project/lib-rql/)\n[![PyPI Downloads](https://img.shields.io/pypi/dm/lib-rql)](https://pypi.org/project/lib-rql/)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=lib-rql&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=lib-rql)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=lib-rql&metric=coverage)](https://sonarcloud.io/summary/new_code?id=lib-rql)\n\n\n\n## Introduction\n\nRQL (Resource query language) is designed for modern application development. It is built for the web, ready for NoSQL, and highly extensible with simple syntax.\nThis is a query language fast and convenient database interaction. RQL was designed for use in URLs to request object-style data structures.\n\n[RQL Reference](https://connect.cloudblue.com/community/api/rql/)\n\n## Install\n\n`Python RQL` can be installed from [pypi.org](https://pypi.org/project/lib-rql/) using pip:\n\n```\n$ pip install lib-rql\n```\n\n## Documentation\n\n[`Python RQL` documentation](https://lib-rql.readthedocs.io/en/latest/) is hosted on the _Read the Docs_ service.\n\n\n## Projects using Python RQL\n\n`Django RQL` is the Django app, that adds RQL filtering to your application.\n\nVisit the [Django RQL](https://github.com/cloudblue/django-rql) project repository for more informations.\n\n\n## Notes\n\nParsing is done with [Lark](https://github.com/lark-parser/lark) ([cheatsheet](https://lark-parser.readthedocs.io/en/latest/lark_cheatsheet.pdf)).\nThe current parsing algorithm is [LALR(1)](https://www.wikiwand.com/en/LALR_parser) with standard lexer.\n\n0. Values with whitespaces or special characters, like ',' need to have \"\" or ''\n1. Supported date format is ISO8601: 2019-02-12\n2. Supported datetime format is ISO8601: 2019-02-12T10:02:00 / 2019-02-12T10:02Z / 2019-02-12T10:02:00+03:00\n\n\n## Supported operators\n\n1. Comparison (eq, ne, gt, ge, lt, le, like, ilike, search)\n2. List (in, out)\n3. Logical (and, or, not)\n4. Constants (null(), empty())\n5. Ordering (ordering)\n6. Select (select)\n7. Tuple (t)\n\n\n## Examples\n\n### Parsing a RQL query\n\n\n```python\nfrom py_rql import parse\nfrom py_rql.exceptions import RQLFilterError\n\ntry:\n    tree = parse('eq(key,value)')\nexcept RQLFilterError:\n    pass\n```\n\n\n### Filter a list of dictionaries\n\n```python\nfrom py_rql.constants import FilterTypes\nfrom py_rql.filter_cls import FilterClass\n\n\nclass BookFilter(FilterClass):\n    FILTERS = [\n        {\n            'filter': 'title',\n        },\n        {\n            'filter': 'author.name',\n        },\n        {\n            'filter': 'status',\n        },\n        {\n            'filter': 'pages',\n            'type': FilterTypes.INT,\n        },\n        {\n            'filter': 'featured',\n            'type': FilterTypes.BOOLEAN,\n        },\n        {\n            'filter': 'publish_date',\n            'type': FilterTypes.DATETIME,\n        },\n    ]\n\nfilters = BookFilter()\n\nquery = 'eq(title,Practical Modern JavaScript)'\nresults = list(filters.filter(query, DATA))\n\nprint(results)\n\nquery = 'or(eq(pages,472),lt(pages,400))'\nresults = list(filters.filter(query, DATA))\n\nprint(results)\n```\n\n\n## Development\n\n\n1. Python 3.8+\n0. Install dependencies `pip install poetry && poetry install`\n\n## Testing\n\n1. Python 3.8+\n0. Install dependencies `pip install poetry && poetry install`\n\nCheck code style: `poetry run flake8`\nRun tests: `poetry run pytest`\n\nTests reports are generated in `tests/reports`.\n* `out.xml` - JUnit test results\n* `coverage.xml` - Coverage xml results\n\nTo generate HTML coverage reports use:\n`--cov-report html:tests/reports/cov_html`\n\n## License\n\n`Python RQL` is released under the [Apache License Version 2.0](https://www.apache.org/licenses/LICENSE-2.0).\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Python RQL Filtering",
    "version": "2.0.0",
    "project_urls": {
        "Homepage": "https://connect.cloudblue.com/community/api/rql/",
        "Repository": "https://github.com/cloudblue/lib-rql"
    },
    "split_keywords": [
        "rql",
        "filter"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3c9738d71b845ef1b39c0630a1b716aeae5498ff6c14585dafec31d6a0303ee3",
                "md5": "a3a72157e1c71dd351d467c49b413993",
                "sha256": "c7f21a69a213665174879f68873b71a8f66765fc8c85517bfa2401e3b85b49cb"
            },
            "downloads": -1,
            "filename": "lib_rql-2.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a3a72157e1c71dd351d467c49b413993",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4",
            "size": 14263,
            "upload_time": "2023-05-30T12:20:50",
            "upload_time_iso_8601": "2023-05-30T12:20:50.433387Z",
            "url": "https://files.pythonhosted.org/packages/3c/97/38d71b845ef1b39c0630a1b716aeae5498ff6c14585dafec31d6a0303ee3/lib_rql-2.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e104d42cd16ace7f0d53f51c8e8b904cf27457dac6d42c5631d4ce1459e2d474",
                "md5": "05e9fba804f57cd173a75ca6bf19b579",
                "sha256": "94a0ad940e6bbb35afa09eb41b58880afaf80f25b39341fef3e0a9bba2b63564"
            },
            "downloads": -1,
            "filename": "lib_rql-2.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "05e9fba804f57cd173a75ca6bf19b579",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4",
            "size": 13550,
            "upload_time": "2023-05-30T12:20:52",
            "upload_time_iso_8601": "2023-05-30T12:20:52.282887Z",
            "url": "https://files.pythonhosted.org/packages/e1/04/d42cd16ace7f0d53f51c8e8b904cf27457dac6d42c5631d4ce1459e2d474/lib_rql-2.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-30 12:20:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cloudblue",
    "github_project": "lib-rql",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "lib-rql"
}
        
Elapsed time: 0.12838s