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.5.8.tar.gz (28.4 kB view details)

Uploaded Source

Built Distribution

python_odata-0.5.8-py3-none-any.whl (35.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: python_odata-0.5.8.tar.gz
  • Upload date:
  • Size: 28.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.9.13 Windows/10

File hashes

Hashes for python_odata-0.5.8.tar.gz
Algorithm Hash digest
SHA256 268aeb8d772a810d50c720990e1478c9366f02133c680935e85d6e0ca9ef4213
MD5 0a4fd7d7a0ec2d35c7cbfea09a2fae54
BLAKE2b-256 35b8429c9e8ef86ff7ac0a63139044e82f03719d455ec60a6c475f7ab3149ad5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_odata-0.5.8-py3-none-any.whl
  • Upload date:
  • Size: 35.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.9.13 Windows/10

File hashes

Hashes for python_odata-0.5.8-py3-none-any.whl
Algorithm Hash digest
SHA256 5171aeb40a0ed3446e4f5271239be7e413228337c30df5590bd6b92cff8bd70d
MD5 548bc32d5109307983e5a6f6cf0b8073
BLAKE2b-256 08d3f9c9e136ffd347773b733e32f2731e80d3743f3f1dbfba7087687dd1f214

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