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
Release history Release notifications | RSS feed
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.0.tar.gz
(28.3 kB
view details)
Built Distribution
File details
Details for the file python_odata-0.5.0.tar.gz
.
File metadata
- Download URL: python_odata-0.5.0.tar.gz
- Upload date:
- Size: 28.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.1 CPython/3.11.1 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eef719748bb7b30a1108855d2a066c77af4baa9c4074c5a0d20491c3b730da0c |
|
MD5 | 45aec9cdaf54a17ed12ec430ca85e69b |
|
BLAKE2b-256 | a6257e4dce5c2f94ae73e7d2ef3662a002f4a9adfc363066f04db8a8dd9df26f |
File details
Details for the file python_odata-0.5.0-py3-none-any.whl
.
File metadata
- Download URL: python_odata-0.5.0-py3-none-any.whl
- Upload date:
- Size: 34.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.1 CPython/3.11.1 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1557dd1755bfd704d71531a6e192af73093e3cd80a3bcd4fde40b16c14401f1 |
|
MD5 | a263db44865699ce987fbc45b6f8e9b8 |
|
BLAKE2b-256 | 7ba00143bc3e6e4aa986c3e3d0c8c3c8e5a6cbc48c068650f2bf7e85f18d2b7f |