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.5.tar.gz
(28.2 kB
view details)
Built Distribution
File details
Details for the file python_odata-0.5.5.tar.gz
.
File metadata
- Download URL: python_odata-0.5.5.tar.gz
- Upload date:
- Size: 28.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.9.13 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ad6c8d49af9b0cd090bd3f5c37a8d1487a2faccf05fce2357d0bf174d6d1d09 |
|
MD5 | e151ccbd562ad8a93e01ea7c05ce2b80 |
|
BLAKE2b-256 | 81519a89a49a368232c378033dfc77da01b1373259fccb153ee193d25e67a2b5 |
File details
Details for the file python_odata-0.5.5-py3-none-any.whl
.
File metadata
- Download URL: python_odata-0.5.5-py3-none-any.whl
- Upload date:
- Size: 35.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.9.13 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5ec5b9ffa53716aee5d4283d8d0d7b661076b6ea5943d6c38507c3ff53ec678 |
|
MD5 | d5de346eee66128a926ead5a40a7e609 |
|
BLAKE2b-256 | 3cd20a11d3d394a20450c7b4a3d83aa70dabc062acdd16d2690b0ccfb8bc3d8b |