Skip to content

Repository files navigation

duckQL 🐥

PyPi packageTestscodecovFOSSA 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.

fromduckqlimportQuery, Property, Comparision, Constantmy_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.

About

JSON-based SQL representation library

Topics

Resources

Code of conduct

Stars

4 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages