duckql


Nameduckql JSON
Version 0.14.0 PyPI version JSON
download
home_pagehttps://github.com/Sibyx/duckql-python
SummaryJSON declarative SQL conversion library
upload_time2025-01-17 16:26:40
maintainerNone
docs_urlNone
authorJakub Dubec
requires_pythonNone
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # duckQL 🐥

![PyPi package](https://img.shields.io/pypi/v/duckql)
![Tests](https://github.com/Sibyx/duckql-python/workflows/Tests/badge.svg)
[![codecov](https://codecov.io/gh/Sibyx/duckql-python/branch/master/graph/badge.svg)](https://codecov.io/gh/Sibyx/duckql-python)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FSibyx%2Fduckql-python.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2FSibyx%2Fduckql-python?ref=badge_shield)

duckQL is simple JSON-based notation for some SQL dialects (PostgreSQL, MariaDB, MySQL) based on
[pydantic](https://github.com/samuelcolvin/pydantic/) library.

## Example

Here is a simple example of library usage. For more examples please visit
[project page](https://sibyx.github.io/duckql-python/).

```python
from duckql import Query, Property, Comparision, Constant


my_query = Query(
    entity='users',
    properties=[
        Property(name='users.name'),
        Property(name='users.surname')
    ],
    conditions=Comparision(
        properties=[
            Property(name='users.age'),
            Constant(value=15)
        ],
        operation=Comparision.Operation.GREATER_EQUAL
    )
)
```

```json
{
  "obj": "structures.Query",
  "entity": "users",
  "properties": [
    {
      "obj": "properties.Property",
      "name": "users.name"
    },
    {
      "obj": "properties.Property",
      "name": "users.surname"
    }
  ],
  "conditions": {
    "obj": "structures.Comparision",
    "properties": [
      {
        "obj": "properties.Property",
        "name": "users.age"
      },
      {
        "obj": "properties.Constant",
        "value": "15"
      }
    ],
    "operation": "gte"
  }
}
```

```postgresql
SELECT users.name, users.surname FROM users WHERE (users.age >= 15);
```

## Development

Project is using [poetry](https://python-poetry.org/) and documentation is generated by
[MkDocs](https://www.mkdocs.org/). If you want to generate documentation you need to follow these simple steps
inside of your virtual environment:

1. `poetry install`
2. `mkdocs build`

Inside of your virtual environment, you can also use `mkdocs serve` to create temporary auto-reload http server with
live docs.

We use [pytest](https://docs.pytest.org/en/latest/) for unit tests and [flake8](https://flake8.pycqa.org/en/latest/)
for code-style validation. You can execute tests inside of pipenv shell using these commands:

- `pytest -v .`: executes unit tests
- `pytest -v --flake8 .`: flake8 code-style tests

## License
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FSibyx%2Fduckql-python.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2FSibyx%2Fduckql-python?ref=badge_large)

---
Made with ☕️ and ❤️ by Jakub Dubec & [BACKBONE s.r.o.](https://www.backbone.sk/en/)

# Changelog

## 0.14.0 : 2024-01-12

⚠️ This release is not working with Python 3.13 and 3.12!! ⚠️

Chores, chores and chores. This will be probably the last release based on the Pydantic 1.x.

🌈 Pink fluffy unicorns dancing on rainbows 🌈

- **Changed**: Dropped support for Python 3.7 and 3.8

## 0.13.0 : 2022-06-09

- **Added**: Ability to use casting for `ORDER BY` property

## 0.12.1 : 2022-05-10

- **Fixed**: Corrected cast of JSON fields

## 0.12.0 : 2021-12-21

- **Feature**: `FirstValue` window function introduced
- **Feature**: Positional `ArrayAgg` introduced

## 0.11.1 : 2021-12-14

- **Change**: Ability to cast to UUID

## 0.11.0 : 2021-12-10

- **Feature**: More benevolent type nesting

## 0.10.0 : 2021-11-30

- **Feature**: `Case` introduced (without docs, there was no time, sry, let's call it Easter Egg for a while)

## 0.9.1 : 2021-07-20

- **Fix**: Fixed problem with multiple properties in operations (I had to remove comparison property check)

## 0.9.0 : 2021-06-25

- **Fix**: Fixed nested conditions (`Operator` can contain another `Operator`)
- **Change**: Dropped Python 3.6 support

## 0.8.2 : 2020-10-15

- **Fix**: Use `->` instead of `-->`

## 0.8.1 : 2020-10-15

- **Fix**: Use `-->` operator in JSON lookup chaining in nested objects

## 0.8.0 : 2020-10-14

- **Feature**: Nested JSON fields

## 0.7.2 : 2020-08-28

- **Fix**: Use `->>` operator in JSON lookup instead of `->` (cast result as text)

## 0.7.1 : 2020-08-27

- **Fix**: Use quotes in JSON column type keys in `Property`

## 0.7.0 : 2020-08-27

- **Feature**: Now is possible to pass `Distinct` to `Count` to have `COUNT(DISTINCT property)` syntax in pSQL
- **Tests**: Test for JSON column type in pSQL

## 0.6.1 : 2020-08-04

- **Fix**: Use native `typing.Literal` if possible (Python 3.8 compatibility fix)

## 0.6.0 : 2020-07-23

- **Feature**: `lower` function introduced
- **Feature**: `upper` function introduced
- **Feature**: pSQL `initcap` function introduced

## 0.5.0 : 2020-07-22

- **Feature**: `QueryFactory` supporting `json`, `msgpack` and `bson`
- **Feature**: pSQL `unaccent` function introduced

## 0.4.0 : 2020-06-12

- **Feature**: `Extract.Unit.DAY` introduced
- **Feature**: `CastOperator.DataType.REAL` introduced
- **Feature**: pSQL `to_char` function introduced
- **Feature**: pSQL `to_date` function introduced

## 0.3.0 : 2020-05-20

- **Feature**: `HAVING` support
- **Feature**: `NOW()` support
- **Fix**: `Comparision` allows to have every `BaseType` as `properties`
- **Fix**: Interval value is quoted now

## 0.2.2 : 2020-04-16

- **Change**: Ability to pass `structures.Distinct` into `functions.StringAgg`

## 0.2.1 : 2020-04-09

- **Fix**: Fixed JOIN aliases

## 0.2.0 : 2020-04-09

Project renamed to `duckql`, this is the first public release (development status modifier changed to beta).

- **Change**: Name changed to `duckql`
- **Change**: [Poetry](https://python-poetry.org/) as package manager

## 0.1.8 : 2020-04-07

- **Feature**: Subquery support
- **Note**: Changelog datetimes in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) compatible `Y-m-d` format

## 0.1.7 : 2020-03-17

- **Fix**: Adding missing imports in `__init__.py` files inside of submodules
- **Change**: Moved `__version__` from `__init__.py` to `version.py`
- **Note**: Development status change to Alpha

## 0.1.6 : 2020-03-13

- **Feature**: Introduced `functions.StringAgg`
- **Feature**: Introduced `structures.CastOperator`
- **Feature**: CLI for parsing files

## 0.1.5 : 2020-02-05

- **Change**: Allow direct use of `structures.Comparision` in query conditions

## 0.1.4 : 2020-02-05

- **Fix**: Allow aliases in `structures.Query`
- **Change**: Do not escape `%`

## 0.1.3 : 2020-02-03

- **Feature**: Natural join support

## 0.1.2 : 2020-02-03

- **Change**: Completed docs
- **Feature**: Recursive nested properties lookup in `Query` object

## 0.1.1 : 2020-02-26

- **Change**: Default values for optional attributes in `structures.Query`
- **Change**: `custom_parser` now can raise `ParseError` if there is invalid object type passed

## 0.1.0 : 2020-02-26

- Initial release

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Sibyx/duckql-python",
    "name": "duckql",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Jakub Dubec",
    "author_email": "jakub.dubec@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/bd/2a/df75a50ff56e7c5353dc25fc36c2bcb257233c9d5efd68d0e4cf4164ffba/duckql-0.14.0.tar.gz",
    "platform": null,
    "description": "# duckQL \ud83d\udc25\n\n![PyPi package](https://img.shields.io/pypi/v/duckql)\n![Tests](https://github.com/Sibyx/duckql-python/workflows/Tests/badge.svg)\n[![codecov](https://codecov.io/gh/Sibyx/duckql-python/branch/master/graph/badge.svg)](https://codecov.io/gh/Sibyx/duckql-python)\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FSibyx%2Fduckql-python.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2FSibyx%2Fduckql-python?ref=badge_shield)\n\nduckQL is simple JSON-based notation for some SQL dialects (PostgreSQL, MariaDB, MySQL) based on\n[pydantic](https://github.com/samuelcolvin/pydantic/) library.\n\n## Example\n\nHere is a simple example of library usage. For more examples please visit\n[project page](https://sibyx.github.io/duckql-python/).\n\n```python\nfrom duckql import Query, Property, Comparision, Constant\n\n\nmy_query = Query(\n    entity='users',\n    properties=[\n        Property(name='users.name'),\n        Property(name='users.surname')\n    ],\n    conditions=Comparision(\n        properties=[\n            Property(name='users.age'),\n            Constant(value=15)\n        ],\n        operation=Comparision.Operation.GREATER_EQUAL\n    )\n)\n```\n\n```json\n{\n  \"obj\": \"structures.Query\",\n  \"entity\": \"users\",\n  \"properties\": [\n    {\n      \"obj\": \"properties.Property\",\n      \"name\": \"users.name\"\n    },\n    {\n      \"obj\": \"properties.Property\",\n      \"name\": \"users.surname\"\n    }\n  ],\n  \"conditions\": {\n    \"obj\": \"structures.Comparision\",\n    \"properties\": [\n      {\n        \"obj\": \"properties.Property\",\n        \"name\": \"users.age\"\n      },\n      {\n        \"obj\": \"properties.Constant\",\n        \"value\": \"15\"\n      }\n    ],\n    \"operation\": \"gte\"\n  }\n}\n```\n\n```postgresql\nSELECT users.name, users.surname FROM users WHERE (users.age >= 15);\n```\n\n## Development\n\nProject is using [poetry](https://python-poetry.org/) and documentation is generated by\n[MkDocs](https://www.mkdocs.org/). If you want to generate documentation you need to follow these simple steps\ninside of your virtual environment:\n\n1. `poetry install`\n2. `mkdocs build`\n\nInside of your virtual environment, you can also use `mkdocs serve` to create temporary auto-reload http server with\nlive docs.\n\nWe use [pytest](https://docs.pytest.org/en/latest/) for unit tests and [flake8](https://flake8.pycqa.org/en/latest/)\nfor code-style validation. You can execute tests inside of pipenv shell using these commands:\n\n- `pytest -v .`: executes unit tests\n- `pytest -v --flake8 .`: flake8 code-style tests\n\n## License\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FSibyx%2Fduckql-python.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2FSibyx%2Fduckql-python?ref=badge_large)\n\n---\nMade with \u2615\ufe0f and \u2764\ufe0f by Jakub Dubec & [BACKBONE s.r.o.](https://www.backbone.sk/en/)\n\n# Changelog\n\n## 0.14.0 : 2024-01-12\n\n\u26a0\ufe0f This release is not working with Python 3.13 and 3.12!! \u26a0\ufe0f\n\nChores, chores and chores. This will be probably the last release based on the Pydantic 1.x.\n\n\ud83c\udf08 Pink fluffy unicorns dancing on rainbows \ud83c\udf08\n\n- **Changed**: Dropped support for Python 3.7 and 3.8\n\n## 0.13.0 : 2022-06-09\n\n- **Added**: Ability to use casting for `ORDER BY` property\n\n## 0.12.1 : 2022-05-10\n\n- **Fixed**: Corrected cast of JSON fields\n\n## 0.12.0 : 2021-12-21\n\n- **Feature**: `FirstValue` window function introduced\n- **Feature**: Positional `ArrayAgg` introduced\n\n## 0.11.1 : 2021-12-14\n\n- **Change**: Ability to cast to UUID\n\n## 0.11.0 : 2021-12-10\n\n- **Feature**: More benevolent type nesting\n\n## 0.10.0 : 2021-11-30\n\n- **Feature**: `Case` introduced (without docs, there was no time, sry, let's call it Easter Egg for a while)\n\n## 0.9.1 : 2021-07-20\n\n- **Fix**: Fixed problem with multiple properties in operations (I had to remove comparison property check)\n\n## 0.9.0 : 2021-06-25\n\n- **Fix**: Fixed nested conditions (`Operator` can contain another `Operator`)\n- **Change**: Dropped Python 3.6 support\n\n## 0.8.2 : 2020-10-15\n\n- **Fix**: Use `->` instead of `-->`\n\n## 0.8.1 : 2020-10-15\n\n- **Fix**: Use `-->` operator in JSON lookup chaining in nested objects\n\n## 0.8.0 : 2020-10-14\n\n- **Feature**: Nested JSON fields\n\n## 0.7.2 : 2020-08-28\n\n- **Fix**: Use `->>` operator in JSON lookup instead of `->` (cast result as text)\n\n## 0.7.1 : 2020-08-27\n\n- **Fix**: Use quotes in JSON column type keys in `Property`\n\n## 0.7.0 : 2020-08-27\n\n- **Feature**: Now is possible to pass `Distinct` to `Count` to have `COUNT(DISTINCT property)` syntax in pSQL\n- **Tests**: Test for JSON column type in pSQL\n\n## 0.6.1 : 2020-08-04\n\n- **Fix**: Use native `typing.Literal` if possible (Python 3.8 compatibility fix)\n\n## 0.6.0 : 2020-07-23\n\n- **Feature**: `lower` function introduced\n- **Feature**: `upper` function introduced\n- **Feature**: pSQL `initcap` function introduced\n\n## 0.5.0 : 2020-07-22\n\n- **Feature**: `QueryFactory` supporting `json`, `msgpack` and `bson`\n- **Feature**: pSQL `unaccent` function introduced\n\n## 0.4.0 : 2020-06-12\n\n- **Feature**: `Extract.Unit.DAY` introduced\n- **Feature**: `CastOperator.DataType.REAL` introduced\n- **Feature**: pSQL `to_char` function introduced\n- **Feature**: pSQL `to_date` function introduced\n\n## 0.3.0 : 2020-05-20\n\n- **Feature**: `HAVING` support\n- **Feature**: `NOW()` support\n- **Fix**: `Comparision` allows to have every `BaseType` as `properties`\n- **Fix**: Interval value is quoted now\n\n## 0.2.2 : 2020-04-16\n\n- **Change**: Ability to pass `structures.Distinct` into `functions.StringAgg`\n\n## 0.2.1 : 2020-04-09\n\n- **Fix**: Fixed JOIN aliases\n\n## 0.2.0 : 2020-04-09\n\nProject renamed to `duckql`, this is the first public release (development status modifier changed to beta).\n\n- **Change**: Name changed to `duckql`\n- **Change**: [Poetry](https://python-poetry.org/) as package manager\n\n## 0.1.8 : 2020-04-07\n\n- **Feature**: Subquery support\n- **Note**: Changelog datetimes in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) compatible `Y-m-d` format\n\n## 0.1.7 : 2020-03-17\n\n- **Fix**: Adding missing imports in `__init__.py` files inside of submodules\n- **Change**: Moved `__version__` from `__init__.py` to `version.py`\n- **Note**: Development status change to Alpha\n\n## 0.1.6 : 2020-03-13\n\n- **Feature**: Introduced `functions.StringAgg`\n- **Feature**: Introduced `structures.CastOperator`\n- **Feature**: CLI for parsing files\n\n## 0.1.5 : 2020-02-05\n\n- **Change**: Allow direct use of `structures.Comparision` in query conditions\n\n## 0.1.4 : 2020-02-05\n\n- **Fix**: Allow aliases in `structures.Query`\n- **Change**: Do not escape `%`\n\n## 0.1.3 : 2020-02-03\n\n- **Feature**: Natural join support\n\n## 0.1.2 : 2020-02-03\n\n- **Change**: Completed docs\n- **Feature**: Recursive nested properties lookup in `Query` object\n\n## 0.1.1 : 2020-02-26\n\n- **Change**: Default values for optional attributes in `structures.Query`\n- **Change**: `custom_parser` now can raise `ParseError` if there is invalid object type passed\n\n## 0.1.0 : 2020-02-26\n\n- Initial release\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "JSON declarative SQL conversion library",
    "version": "0.14.0",
    "project_urls": {
        "Homepage": "https://github.com/Sibyx/duckql-python"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b334a555e882ca5fdcc40f616d179cd1932ab3fabdd8c1dd37d2f867b037a66a",
                "md5": "c1040a59d726e6e779bc9260afa229b2",
                "sha256": "25377bc3fc224774a023641f13b4ed5abc70fd48fbdd16525d2da356c942b680"
            },
            "downloads": -1,
            "filename": "duckql-0.14.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c1040a59d726e6e779bc9260afa229b2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 31791,
            "upload_time": "2025-01-17T16:26:37",
            "upload_time_iso_8601": "2025-01-17T16:26:37.773656Z",
            "url": "https://files.pythonhosted.org/packages/b3/34/a555e882ca5fdcc40f616d179cd1932ab3fabdd8c1dd37d2f867b037a66a/duckql-0.14.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bd2adf75a50ff56e7c5353dc25fc36c2bcb257233c9d5efd68d0e4cf4164ffba",
                "md5": "67f076226e5cbd82ad2bddf30193508f",
                "sha256": "f85f9862fc6dd449e07ecdb741795a5266e662524581c2de74cee095717b6a3d"
            },
            "downloads": -1,
            "filename": "duckql-0.14.0.tar.gz",
            "has_sig": false,
            "md5_digest": "67f076226e5cbd82ad2bddf30193508f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 18157,
            "upload_time": "2025-01-17T16:26:40",
            "upload_time_iso_8601": "2025-01-17T16:26:40.514984Z",
            "url": "https://files.pythonhosted.org/packages/bd/2a/df75a50ff56e7c5353dc25fc36c2bcb257233c9d5efd68d0e4cf4164ffba/duckql-0.14.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-17 16:26:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Sibyx",
    "github_project": "duckql-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "duckql"
}
        
Elapsed time: 0.51646s