No project description provided
Project description
Pydantic MQL
This library can parse and evaluate conditions using pydantic. The usage is similar to the MongoDB Query Language. But instead of filtering documents within a database collection you can use the library to filter arbitrary application data in memory.
Example Usage
Parsing
from pydantic_mql import Condition
test_json = '{"operator": "$eq", "field": "label", "value": "lab"}'
condition = Condition.model_validate_json(test_json)
print(condition)
Serializing
from pydantic_mql import Condition
condition = Condition(operator='$and', conditions=[
Condition(operator='$eq', field='label', value='lab'),
Condition(operator='$lte', field='rating', value=80)
])
print(condition.model_dump())
Condition Eval
test_data = {'rating': 60, 'label': 'lab'}
result = condition.eval(test_data)
print(result)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pydantic-mql-0.1.0.tar.gz
(4.1 kB
view hashes)
Built Distribution
Close
Hashes for pydantic_mql-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f5166543994241262cbedfabff3ce5acf043c72b093024c94c4b00cb0aed39f |
|
MD5 | 02653c095f5af17864b214a7dd41ffcd |
|
BLAKE2b-256 | 8fb98d5ecfe64a71b6f23de023fe7b00dca5127457e9031a5d4708f94ae24bc3 |