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.1.tar.gz
(28.3 kB
view hashes)
Built Distribution
Close
Hashes for python_odata-0.5.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8bc2cd90e0be383a8d2895463e3b1bc377c6e4ec69e53465b80601bf1d51fa9d |
|
MD5 | 4b9e0059ab58861c897fe027c020999f |
|
BLAKE2b-256 | f222ccbe36645388f6b87af514564f35776af6673cc02b929a740c3b73d72d35 |