pyodata is an enterprise-ready Python OData client that provides a comfortable and Python-agnostic way to communicate with OData services. It abstracts away OData protocol implementation details, primarily supporting OData V2, with future plans for V4 support. The library is actively maintained, with frequent minor releases, and its current version is 1.11.2.
pip install -U pyodataVerified import paths — ran on the pinned version, not inferred.
Initializes an OData client using `requests.Session` and queries the 'Products' entity set from the Northwind OData V2 sample service. This demonstrates basic client setup and data retrieval.
Upgrade your Python environment to 3.9 or newer.
Before making a POST/PATCH request, execute a HEAD request to the service URL to obtain the 'x-csrf-token' and 'set-cookie' headers, then include them in subsequent requests. Example: `session.head(SERVICE_URL, headers={'x-csrf-token': 'fetch'})`.Configure the metadata parser to recover from problems using `pyodata.Client`'s `config` parameter. You can specify parser policies (e.g., `PolicyWarning`, `PolicyIgnore`) and set `retain_null=False` to prevent substitution by default values.
Use the `config` object (e.g., `pyodata.client.config`) to manage XML namespaces and other parser settings instead.
Use the `.custom(name, value)` method on entity requests to add custom query parameters. To disable URL path encoding, set `encode_path=False` during client initialization or on the request.