QueryResult

class borneo.QueryResult(request, computed=True)[source]

Bases: borneo.operations.Result

QueryResult comprises a list of dict instances representing the query results.

The shape of the values is based on the schema implied by the query. For example a query such as “SELECT * FROM …” that returns an intact row will return values that conform to the schema of the table. Projections return instances that conform to the schema implied by the statement. UPDATE queries either return values based on a RETURNING clause or, by default, the number of rows affected by the statement.

A single QueryResult does not imply that all results for the query have been returned. If the value returned by QueryRequest.is_done() is False there are additional results available. This can happen even if there are no values in the returned QueryResult. The best way to use QueryRequest and QueryResult is to perform operations in a loop, for example:

handle = ...
request = QueryRequest().set_statement('SELECT * FROM foo')
while True:
    result = handle.query(request)
    results = result.get_results()
    # do something with the results
    if request.is_done():
        break

Modification queries either return values based on a RETURNING clause or, by default, return the number of rows affected by the statement in a dictionary. INSERT queries with no RETURNING clause return a dictionary indicating the number of rows inserted, for example {‘NumRowsInserted’: 5}. UPDATE queries with no RETURNING clause return a dictionary indicating the number of rows updated, for example {‘NumRowsUpdated’: 3}. DELETE queries with no RETURNING clause return a dictionary indicating the number of rows deleted, for example {‘numRowsDeleted’: 2}.

Methods Summary

get_continuation_key() Returns the continuation key that can be used to obtain more results if non-none.
get_read_kb() Returns the read throughput consumed by this operation, in KBytes.
get_read_units() Returns the read throughput consumed by this operation, in read units.
get_results() Returns a list of results for the query.
get_write_kb() Returns the write throughput consumed by this operation, in KBytes.
get_write_units() Returns the write throughput consumed by this operation, in write units.

Methods Documentation

get_continuation_key()[source]

Returns the continuation key that can be used to obtain more results if non-none.

Returns:the continuation key, or None if there are no further values to return.
Return type:bytearray
get_read_kb()[source]

Returns the read throughput consumed by this operation, in KBytes. This is the actual amount of data read by the operation. The number of read units consumed is returned by get_read_units() which may be a larger number if the operation used Consistency.ABSOLUTE.

Returns:the read KBytes consumed.
Return type:int
get_read_units()[source]

Returns the read throughput consumed by this operation, in read units. This number may be larger than that returned by get_read_kb() if the operation used Consistency.ABSOLUTE.

Returns:the read units consumed.
Return type:int
get_results()[source]

Returns a list of results for the query. It is possible to have an empty list and a non-none continuation key.

Returns:a list of results for the query.
Return type:list(dict)
get_write_kb()[source]

Returns the write throughput consumed by this operation, in KBytes.

Returns:the write KBytes consumed.
Return type:int
get_write_units()[source]

Returns the write throughput consumed by this operation, in write units.

Returns:the write units consumed.
Return type:int