Skip to main content

A simple library for read/write access to OData services.

Project description

python-odata

A simple library for read/write access to OData services.

  • Supports OData version 4.0
  • Requires JSON format support from the service
  • Should work on both Python 2.x and 3.x

Documentation

Available on readthedocs.org

Dependencies

  • requests >= 2.0
  • python-dateutil
  • rich >= 13.3.1

Demo

Reading data from the Northwind service.

from odata import ODataService
url = 'http://services.odata.org/V4/Northwind/Northwind.svc/'
Service = ODataService(url, reflect_entities=True)
Supplier = Service.entities['Supplier']

query = Service.query(Supplier)
query = query.limit(2)
query = query.order_by(Supplier.CompanyName.asc())

for supplier in query:
    print('Company:', supplier.CompanyName)

    for product in supplier.Products:
        print('- Product:', product.ProductName)

Writing changes. Note that the real Northwind service is read-only and the data modifications do not work against it.

import datetime

Order = Service.entities['Order']
Employee = Service.entities['Employee']

empl = Service.query(Employee).first()

query = Service.query(Order)
query = query.filter(Order.ShipCity == 'Berlin')

for order in query:
    order.ShippedDate = datetime.datetime.utcnow() 
    order.Employee = empl
    Service.save(order)

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

python_odata-0.4.tar.gz (68.6 kB view details)

Uploaded Source

Built Distribution

python_odata-0.4-py3-none-any.whl (49.9 kB view details)

Uploaded Python 3

File details

Details for the file python_odata-0.4.tar.gz.

File metadata

  • Download URL: python_odata-0.4.tar.gz
  • Upload date:
  • Size: 68.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.11.1 Windows/10

File hashes

Hashes for python_odata-0.4.tar.gz
Algorithm Hash digest
SHA256 b838e93b12964bb71f692bb00111b56688d6270516a0b89c14d81af36ca9e17a
MD5 0cb32b7e22de87a9e8d43732bd3efc20
BLAKE2b-256 36d2ca77f4aefdd9d9f679230a3323d2d940eab74b75fd9bbe697d04f58313e1

See more details on using hashes here.

File details

Details for the file python_odata-0.4-py3-none-any.whl.

File metadata

  • Download URL: python_odata-0.4-py3-none-any.whl
  • Upload date:
  • Size: 49.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.11.1 Windows/10

File hashes

Hashes for python_odata-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 815d37eac3bfd82d79a531457967db759e707338d51b0f540454295bc5630720
MD5 7b3978a65dc59f7e6c297249bbbf253a
BLAKE2b-256 83fb3f7cdf5e2ae2b240a16b10f8675cfd0266f7ea0b48a16c93d8ae605933e8

See more details on using hashes here.

Supported by

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