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.4.1.tar.gz
(27.8 kB
view details)
Built Distribution
File details
Details for the file python_odata-0.4.1.tar.gz
.
File metadata
- Download URL: python_odata-0.4.1.tar.gz
- Upload date:
- Size: 27.8 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 | db57f7f966d37f974f278a03fc4749caa4bcc204a95423081665918af0d9e864 |
|
MD5 | 3c6970d5992cd10c928e3bb99183375f |
|
BLAKE2b-256 | b84b37352998be09345be85649c8e91d2b775608789bcd2988a51cc7845e5391 |
File details
Details for the file python_odata-0.4.1-py3-none-any.whl
.
File metadata
- Download URL: python_odata-0.4.1-py3-none-any.whl
- Upload date:
- Size: 32.0 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 | d780291f9baeff8f09b1af2b9003adf3cdddbea243434261005b741388c61ab0 |
|
MD5 | 154ed916ecd9ea45b9729e3b8ad834cd |
|
BLAKE2b-256 | 261fa3c714b51adef27f04e059cb9a8495af42f9b930cc37cfd9877d263dfb08 |