Module neug.query_result
The Neug result module.
QueryResult Objects
class QueryResult(object)QueryResult represents the result of a cypher query. Could be visited as a iterator.
It has the following methods to iterate over the results.
- hasNext(): Returns True if there are more results to iterate over.
- getNext(): Returns the next result as a list.
- length(): Returns the total number of results.
- column_names(): Returns the projected column names as strings.
- get_profile_metrics(): Returns structured PROFILE or EXPLAIN metrics.
>>> from neug import Database
>>> db = Database("/tmp/test.db", mode="r")
>>> conn = db.connect()
>>> result = conn.execute('MATCH (n) RETURN n')
>>> for row in result:
>>> print(row)
__init__
def __init__(result)Initialize the QueryResult.
- Parameters:
result(PyQueryResult) The result of the query, returned by the query engine. It is a C++ object and is exported to python via pybind.
column_names
def column_names()Return the projected column names as a list of strings.
get_bolt_response
def get_bolt_response() -> strGet the result in Bolt response format. TODO(zhanglei,xiaoli): Make sure the format consistency with neo4j bolt response.
- Returns:
- str The result in Bolt response format.
get_profile_metrics
def get_profile_metrics() -> dictReturn detailed PROFILE or EXPLAIN metrics as a Python dictionary:
{
"total_elapsed_ms": float,
"total_output_rows": int,
"operators": [
{
"operator_id": int,
"parent_id": int,
"operator_name": str,
"elapsed_ms": float,
"output_rows": int,
"child_ids": [int],
}
],
}to_arrow
def to_arrow()Convert the result to an Arrow table.
- Returns:
- pyarrow.Table The result converted to an Arrow table.