Skip to main content
Documentation Status Code style: black

odata-query is a library that parses OData v4 filter strings, and can convert them to other forms such as Django Queries, SQLAlchemy Queries, or just plain SQL.

Installation

odata-query is available on pypi, so can be installed with the package manager of your choice:

pip install odata-query
# OR
poetry add odata-query
# OR
pipenv install odata-query

The package defines the following optional extra’s:

  • django: If you want to pin a compatible Django version.

  • sqlalchemy: If you want to pin a compatible SQLAlchemy version.

The following extra’s relate to the development of this library:

  • linting: The linting and code style tools.

  • testing: Packages for running the tests.

  • docs: For building the project documentation.

You can install extra’s by adding them between square brackets during installation:

pip install odata-query[sqlalchemy]

Quickstart

The most common use case is probably parsing an OData query string, and applying it to a query your ORM understands. For this purpose there is an all-in-one function: apply_odata_query.

Example for Django:

from odata_query.django import apply_odata_query

orm_query = MyModel.objects  # This can be a Manager or a QuerySet.
odata_query = "name eq 'test'"  # This will usually come from a query string parameter.

query = apply_odata_query(orm_query, odata_query)
results = query.all()

Example for SQLAlchemy ORM:

from odata_query.sqlalchemy import apply_odata_query

orm_query = select(MyModel)  # This is any form of Query or Selectable.
odata_query = "name eq 'test'"  # This will usually come from a query string parameter.

query = apply_odata_query(orm_query, odata_query)
results = session.execute(query).scalars().all()

Example for SQLAlchemy Core:

from odata_query.sqlalchemy import apply_odata_core

core_query = select(MyTable)  # This is any form of Query or Selectable.
odata_query = "name eq 'test'"  # This will usually come from a query string parameter.

query = apply_odata_core(core_query, odata_query)
results = session.execute(query).scalars().all()

Advanced Usage

Not all use cases are as simple as that. Luckily, odata-query is modular and extendable. See the documentation for advanced usage or extending the library for other cases.

Contact

Got any questions or ideas? We’d love to hear from you. Check out our contributing guidelines for ways to offer feedback and contribute.

License

Copyright © Gorillini NV. All rights reserved.

Licensed under the MIT License.

Metadata

Release files for odata-query 0.10.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for odata-query 0.10.0
File Size Uploaded
odata_query-0.10.0.tar.gz 28.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for odata-query 0.10.0
File Interpreter ABI Platform
odata_query-0.10.0-py3-none-any.whl Python 3 none any Details

Total release size: 62.9 kB

Release files / odata_query-0.10.0.tar.gz

Download URL odata_query-0.10.0.tar.gz
Size 28.0 kB
Tags Source
SHA-256 checksum
How to use checksums
230d847d334fc36dc072164886711ad794bedec6d864c2600de614c596fc1c4f
BLAKE2b-256 checksum
How to use checksums
ae58b87a8f36b372af232a21b0bde5737506c84544365ad81d4998e1e23b2f3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.9.19 Darwin/23.5.0

Release files / odata_query-0.10.0-py3-none-any.whl

Download URL odata_query-0.10.0-py3-none-any.whl
Size 34.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eeb9061e87fb047c40bc3e59c5f1fbf5dbf4ea0f7ff2fd510d365d6c33fe7fcb
BLAKE2b-256 checksum
How to use checksums
01f691d52932a61a8605b3569788c494c1aaeb8f3423084659ca76041bcd3fe0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.9.19 Darwin/23.5.0

Release history Release notifications | RSS feed

This release

0.10.0 This release

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page