duckQL 🐥
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:
poetry installmkdocs 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 testspytest -v --flake8 .: flake8 code-style tests
License
Made with ☕️ and ❤️ by Jakub Dubec & BACKBONE s.r.o.
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 BYproperty
0.12.1 : 2022-05-10
- Fixed: Corrected cast of JSON fields
0.12.0 : 2021-12-21
- Feature:
FirstValuewindow function introduced - Feature: Positional
ArrayAggintroduced
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:
Caseintroduced (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 (
Operatorcan contain anotherOperator) - 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
DistincttoCountto haveCOUNT(DISTINCT property)syntax in pSQL - Tests: Test for JSON column type in pSQL
0.6.1 : 2020-08-04
- Fix: Use native
typing.Literalif possible (Python 3.8 compatibility fix)
0.6.0 : 2020-07-23
- Feature:
lowerfunction introduced - Feature:
upperfunction introduced - Feature: pSQL
initcapfunction introduced
0.5.0 : 2020-07-22
- Feature:
QueryFactorysupportingjson,msgpackandbson - Feature: pSQL
unaccentfunction introduced
0.4.0 : 2020-06-12
- Feature:
Extract.Unit.DAYintroduced - Feature:
CastOperator.DataType.REALintroduced - Feature: pSQL
to_charfunction introduced - Feature: pSQL
to_datefunction introduced
0.3.0 : 2020-05-20
- Feature:
HAVINGsupport - Feature:
NOW()support - Fix:
Comparisionallows to have everyBaseTypeasproperties - Fix: Interval value is quoted now
0.2.2 : 2020-04-16
- Change: Ability to pass
structures.Distinctintofunctions.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 as package manager
0.1.8 : 2020-04-07
- Feature: Subquery support
- Note: Changelog datetimes in ISO 8601 compatible
Y-m-dformat
0.1.7 : 2020-03-17
- Fix: Adding missing imports in
__init__.pyfiles inside of submodules - Change: Moved
__version__from__init__.pytoversion.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.Comparisionin 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
Queryobject
0.1.1 : 2020-02-26
- Change: Default values for optional attributes in
structures.Query - Change:
custom_parsernow can raiseParseErrorif there is invalid object type passed
0.1.0 : 2020-02-26
- Initial release
Metadata
Release files for duckql 0.14.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| duckql-0.14.0.tar.gz | 18.2 kB | Without provenance | Details for duckql-0.14.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| duckql-0.14.0-py3-none-any.whl | Python 3 | none | any | Details for duckql-0.14.0-py3-none-any.whl |
Total release size: 49.9 kB
Release files / duckql-0.14.0.tar.gz
| Download URL | duckql-0.14.0.tar.gz |
|---|---|
| Size | 18.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f85f9862fc6dd449e07ecdb741795a5266e662524581c2de74cee095717b6a3d
|
|
BLAKE2b-256 checksum How to use checksums |
bd2adf75a50ff56e7c5353dc25fc36c2bcb257233c9d5efd68d0e4cf4164ffba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.0
|
Release files / duckql-0.14.0-py3-none-any.whl
| Download URL | duckql-0.14.0-py3-none-any.whl |
|---|---|
| Size | 31.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
25377bc3fc224774a023641f13b4ed5abc70fd48fbdd16525d2da356c942b680
|
|
BLAKE2b-256 checksum How to use checksums |
b334a555e882ca5fdcc40f616d179cd1932ab3fabdd8c1dd37d2f867b037a66a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.0
|
Security for duckql 0.14.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.