|
1 | 1 | #!/usr/bin/env python
|
2 | 2 | from datetime import date, timedelta
|
3 | 3 | from random import randint
|
4 |
| -from databox import insert_all |
5 | 4 | from os import getenv
|
6 | 5 |
|
7 | 6 | """
|
|
14 | 13 |
|
15 | 14 | client = Client(TOKEN)
|
16 | 15 |
|
17 |
| -# client.push('orders.total', 32, date='2015-01-01 09:00:00') |
18 |
| - |
19 |
| -# key = 'temp.ljx' |
20 |
| -# rows = [] |
21 |
| -# |
22 |
| -# for i, day in enumerate([date.today()-timedelta(days=d) for d in range(0, 14)]): |
23 |
| -# n = 20 + randint(0, 15) |
24 |
| -# rows.append({'key': key, 'value': n, 'date': day.strftime("%Y-%m-%d")}) |
25 |
| -# |
26 |
| -# if insert_all(rows, token=TOKEN): |
27 |
| -# print "Inserted", len(rows), "rows." |
28 |
| -# |
29 |
| -# |
30 |
| - |
31 | 16 | push = client.push('transaction', 1447.4)
|
32 | 17 |
|
33 |
| -print client.insert_all([ |
| 18 | +pushId = client.insert_all([ |
34 | 19 | {'key': 'temp.boston', 'value': 51},
|
35 | 20 | {'key': 'temp.boston', 'value': 49, 'date': '2015-01-01 17:00:00'},
|
36 | 21 | {'key': 'sales.total', 'value': 3000, 'attributes': {
|
|
40 | 25 | {'key': 'transaction', 'value': 45.6, 'unit': 'USD'}
|
41 | 26 | ])
|
42 | 27 |
|
43 |
| -print "--------" |
| 28 | +print ("Push id: ", pushId) |
44 | 29 |
|
45 |
| -lastPushes = client.last_push(3) |
| 30 | +# lastPushes = client.last_push(3) |
| 31 | +# print lastPushes |
46 | 32 |
|
47 |
| -print client.get_push(lastPushes[0]['response']['body']['id']) |
48 |
| -print client.metrics() |
49 |
| -print client.purge() |
| 33 | +print (client.get_push(pushId)) |
| 34 | +print (client.metrics()) |
| 35 | +print (client.purge()) |
0 commit comments