Cursors

The tempoiq.protocol.cursor module contaions functionality for working with database cursors. Each Cursor object is a standard Python iterable that represents a one-time use array of data from the TempoDB API (i.e. after you have iterated through a cursor, you must make another API call to read the data again):

>>> data = [d for d in response.data]
>>> data
[DataPoint, DataPoint, ...]
>>> data2 = [d for d in response.data]
>>> data2
[]
class tempoiq.protocol.cursor.Cursor(data, response)[source]

An iterable cursor over data retrieved from the TempoDB API. The cursor will make network requests to fetch more data as needed, until the API returns no more data. It can be used with the standard iterable interface:

>>> data = [d for d in response.data]
class tempoiq.protocol.cursor.DataPointsCursor(response, data, fetcher)[source]

The data attribute holds the actual data from the request.

Additionally, the raw response object is available as the response attribute of the cursor.

Parameters:response (:class:`tempodb.response.Response) – the raw response object
class tempoiq.protocol.cursor.DeviceCursor(response, data, fetcher)[source]

The data attribute holds the actual data from the request.

Additionally, the raw response object is available as the response attribute of the cursor.

Parameters:response (:class:`tempodb.response.Response) – the raw response object
tempoiq.protocol.cursor.check_response(resp)[source]

Utility function for checking the status of a cursor increment. Raises an exception if the call to the paginated link returns anything other than a 200.

Parameters:resp (tempodb.response.Response object) – the response to check
Raises ValueError:
 if the response is not a 200
Return type:None
tempoiq.protocol.cursor.make_row_generator(rows)[source]

“Utility function for converting a list to a generator.

Parameters:d (list) – the list to convert
Return type:generator