Skip to main content

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


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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydantic_mql-0.1.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file pydantic-mql-0.1.0.tar.gz.

File metadata

  • Download URL: pydantic-mql-0.1.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for pydantic-mql-0.1.0.tar.gz
Algorithm Hash digest
SHA256 439a59216bf1818a4983fdb2a021280f1b1c17c7036f84c039266754ea37a0db
MD5 ae3c4f4e44f5d9c85b1c23b053c62665
BLAKE2b-256 8d821585b1186630530db3af8059930ad0d9835757d7eca6c07b2cb67a47983b

See more details on using hashes here.

File details

Details for the file pydantic_mql-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pydantic_mql-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for pydantic_mql-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0f5166543994241262cbedfabff3ce5acf043c72b093024c94c4b00cb0aed39f
MD5 02653c095f5af17864b214a7dd41ffcd
BLAKE2b-256 8fb98d5ecfe64a71b6f23de023fe7b00dca5127457e9031a5d4708f94ae24bc3

See more details on using hashes here.

Supported by

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