Skip to content

Commit

Permalink
#9 In query response change attribute 'time' to 'timestamp'.
Browse files Browse the repository at this point in the history
  • Loading branch information
Auke Willem Oosterhoff committed Nov 9, 2016
1 parent b042cf5 commit aae4efd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion inflow/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ def parse_query_response(response):
values=[]
)

try:
i = s['columns'].index('time')
s['columns'][i] = 'timestamp'
except ValueError:
pass

for v in s['values']:
parsed['values'].append({
key: value
Expand Down Expand Up @@ -84,10 +90,10 @@ def __init__(self, uri, precision='s', retention_policy=None):
raise ValueError('Should specify a database name.')

self.uri = '{}://{}'.format(

parsed.scheme,
parsed.hostname
)

if parsed.port is not None:
self.uri += ':{}'.format(parsed.port)

Expand Down
6 changes: 3 additions & 3 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,12 @@ def test_get_measurements(self, client, get):
"name": "temperatures",
"values": [
{
"time": "2016-01-01T00:01:00Z",
"timestamp": "2016-01-01T00:01:00Z",
"value": 20.1,
"location": "groningen"
},
{
"time": "2016-01-01T00:02:00Z",
"timestamp": "2016-01-01T00:02:00Z",
"value": 23.0,
"location": "groningen"
}
Expand All @@ -374,7 +374,7 @@ def test_get_measurements(self, client, get):
rv = client.query('SELECT * FROM "temperatures"')
assert rv[0]['name'] == 'temperatures'
assert rv[0]['values'][0] == {
"time": "2016-01-01T00:01:00Z",
"timestamp": "2016-01-01T00:01:00Z",
"value": 20.1,
"location": "groningen"
}
Expand Down

0 comments on commit aae4efd

Please sign in to comment.