Skip to content

Commit dd97eba

Browse files
committed
Update README.md
1 parent 868f2ba commit dd97eba

File tree

1 file changed

+35
-16
lines changed

1 file changed

+35
-16
lines changed

README.md

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,53 @@ When in Databox Designer go to Account > Access tokens, then either create a new
1212

1313
## Using the Databox Python library
1414

15+
To use databox-python libary you have to pass access token to client. You can do this when initialising `Client` or by setting `DATABOX_PUSH_TOKEN` environment variable.
16+
17+
Using `Client` and `push` to push data directly:
18+
1519
```python
16-
from databox import PushClient
20+
from databox import Client
21+
22+
client = Client('<access token>')
23+
client.push('sales.total', 1447.0)
24+
client.push('orders.total', 32, date='2015-01-01 09:00:00')
25+
```
26+
27+
Inserting multiple matrices with one `insert_all`:
1728

18-
# instantiate PushClient
19-
client = PushClient('<access token>')
29+
```python
30+
client.insert_all([
31+
{'key': 'temp.boston', 'value': 51},
32+
{'key': 'temp.boston', 'value': 49, 'date': '2015-01-01 17:00:00'},
33+
{'key': 'sales.total', 'value': 3000},
34+
])
35+
```
36+
37+
Retriving information from last push with `last_push`:
38+
```python
39+
print client.last_push()
40+
```
2041

21-
# push metric "answer1" with value 42 for today
22-
client.add(42, "answer1")
42+
Libary can be used with shorthand methods:
2343

24-
# push metric "answer1" with value 42 for any other day
25-
client.add(42, "answer1", "2015-05-01 10:10:10")
2644

27-
# send to Databox
28-
print client.send()
45+
```python
46+
from databox import push, insert_all, last_push
2947

30-
# get last push
31-
print client.lastPush()
32-
``
48+
push('sales.total', 1448.9)
49+
print last_push(token)
50+
```
3351

34-
Check working sample in [sample1.py](/sample1.py) file.
52+
## Development and testing
3553

36-
## Development
54+
Using virtualenv:
3755

3856
mkvirtualenv --no-site-packages databox-python
3957
workon databox-python
4058
pip install --upgrade -r requirements.txt
4159

42-
# Running test suite
60+
Running test suite with unittest:
61+
4362
python -munittest discover -p -t . 'test*' -v
4463

4564
## Authors and contributions
@@ -49,4 +68,4 @@ Check working sample in [sample1.py](/sample1.py) file.
4968

5069
## Licence
5170

52-
- [MIT](LICENSE.txt)
71+
- [MIT](LICENSE.txt)

0 commit comments

Comments
 (0)