Skip to content

Commit 20b53d9

Browse files
committed
Updated readme to include example for TripPin v4 odata service with enums.
Changelog: changed
1 parent c9611c5 commit 20b53d9

File tree

1 file changed

+53
-3
lines changed

1 file changed

+53
-3
lines changed

README.md

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Available on [readthedocs.org](https://python-odata.readthedocs.io/en/latest/ind
1818

1919
## Demo
2020

21+
### Northwind ODATA service
2122
Reading data from the Northwind service.
2223

2324
```python
@@ -60,9 +61,6 @@ for order_details in values:
6061
service.values(order_details.Order.Employee)
6162
```
6263

63-
Writing changes. Note that the real Northwind service is _read-only_
64-
and the data modifications do not work against it.
65-
6664
```python
6765
import datetime
6866

@@ -79,3 +77,55 @@ for order in query:
7977
order.Employee = empl
8078
Service.save(order)
8179
```
80+
81+
### TripPin ODATA service (v4)
82+
OData V4 example with Enums.
83+
84+
```python
85+
import logging
86+
87+
import requests
88+
import rich
89+
90+
# comment on first run so you get the generated package
91+
import generated.trippin
92+
from odata import ODataService
93+
94+
requests.packages.urllib3.disable_warnings()
95+
96+
97+
def test_trippin(console):
98+
proxy = {'http': '', 'https': ''}
99+
100+
session = requests.Session()
101+
102+
session.trust_env = False
103+
session.verify = False
104+
session.proxies.update(proxy)
105+
106+
service = ODataService(
107+
url="https://services.odata.org/v4/TripPinServiceRW",
108+
session=session,
109+
base=generated.trippin.ReflectionBase, # comment on first run
110+
reflect_entities=True,
111+
reflect_output_package="generated.trippin")
112+
People = generated.trippin.People
113+
114+
q = service.query(People)
115+
116+
values = q.all()
117+
for value in values:
118+
console.rule(f"People {value.FirstName} {value.LastName}")
119+
service.values(value)
120+
121+
122+
if __name__ == "__main__":
123+
logging.basicConfig(level="DEBUG")
124+
console = rich.console.Console()
125+
test_trippin(console)
126+
```
127+
128+
Writing changes. Note that the real Northwind service is _read-only_
129+
and the data modifications do not work against it.
130+
131+

0 commit comments

Comments
 (0)