Skip to content

Sibyx/duckql-python

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

duckQL 🐥

PyPi package Tests codecov FOSSA Status

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

License

FOSSA Status


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