Skip to main content

JSON declarative SQL conversion library

Project description

duckQL

Tests codecov

duckQL is simple JSON-based notation for some SQL dialects (PostgreSQL, MariaDB, MySQL) based on pydantic library.

Example

Here is a simple example of library usage. For more examples please visit project page.

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
    )
)
{
  "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"
  }
}
SELECT users.name, users.surname FROM users WHERE (users.age >= 15);

Development

Project is using poetry and documentation is generated by MkDocs. 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 for unit tests and flake8 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

Made with ☕️ and ❤️ by Jakub Dubec & BACKBONE s.r.o.

Changelog

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 as package manager

0.1.8 : 2020-04-07

  • Feature: Subquery support
  • Note: Changelog datetimes in 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

Project details


Download files

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

Source Distribution

duckql-0.2.0.tar.gz (13.0 kB view hashes)

Uploaded Source

Built Distribution

duckql-0.2.0-py3-none-any.whl (23.9 kB view hashes)

Uploaded Python 3

Supported by

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