# 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": null,
"docs_url": null,
"requires_python": "<4,>=3.8",
"maintainer_email": null,
"keywords": "rql, filter",
"author": "CloudBlue LLC",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/31/d5/6facc0028c6a27f228999cf4990b4b3d1a31b501153e415b7b9b31d24a0a/lib_rql-2.0.2.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.2",
"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": "8e5bc9b11c88114cac3b611f8b5b938aa04d581e95ddc708c56f70d378bda263",
"md5": "b80b1ad51df5ef7df8531c0994e9370a",
"sha256": "2f30cda8e53e269ae2ea6c93f6009b1dc127fcf3aee5027b99de314aa0bbaa7f"
},
"downloads": -1,
"filename": "lib_rql-2.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b80b1ad51df5ef7df8531c0994e9370a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.8",
"size": 14261,
"upload_time": "2024-07-15T18:24:45",
"upload_time_iso_8601": "2024-07-15T18:24:45.345797Z",
"url": "https://files.pythonhosted.org/packages/8e/5b/c9b11c88114cac3b611f8b5b938aa04d581e95ddc708c56f70d378bda263/lib_rql-2.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "31d56facc0028c6a27f228999cf4990b4b3d1a31b501153e415b7b9b31d24a0a",
"md5": "9eae9edee1a49b6a9c515322b4ae8ade",
"sha256": "3c7edfa6f822ff6397181a1d99d71e0dc7273ed2655bd3193c021049c40f726c"
},
"downloads": -1,
"filename": "lib_rql-2.0.2.tar.gz",
"has_sig": false,
"md5_digest": "9eae9edee1a49b6a9c515322b4ae8ade",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.8",
"size": 13547,
"upload_time": "2024-07-15T18:24:46",
"upload_time_iso_8601": "2024-07-15T18:24:46.819419Z",
"url": "https://files.pythonhosted.org/packages/31/d5/6facc0028c6a27f228999cf4990b4b3d1a31b501153e415b7b9b31d24a0a/lib_rql-2.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-15 18:24:46",
"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"
}