grafeo.QueryResult¶
Query result iterator.
Properties¶
| Property | Type | Description |
|---|---|---|
columns | List[str] | Column names |
execution_time_ms | float | Query execution time in milliseconds |
rows_scanned | int | Rows the query read from storage before any filter: nodes its scans and index lookups read, edges its expands read, search hits and RDF triples |
counters | dict | What the query's writes changed: nodes_created, nodes_deleted, edges_created, edges_deleted, properties_set, labels_added, labels_removed |
profile | dict \| None | For a PROFILE statement, its operators as a tree: total_time_ms and root, each operator with operator, detail, rows, calls, self_time_ms, time_ms and children (experimental); None otherwise |
Methods¶
iter()¶
Iterate over rows.
getitem()¶
Access a row by index.
len()¶
Get the number of rows in the result.
to_list()¶
Convert to list of dicts.
scalar()¶
Return the first column of the first row as a scalar value.
nodes()¶
Return all nodes from the result.
edges()¶
Return all edges from the result.
Example¶
result = db.execute("MATCH (p:Person) RETURN p.name, p.age")
# Iterate
for row in result:
print(row['p.name'])
# Length
print(f"Found {len(result)} rows")
# Index access
first_row = result[0]
# Convert to list
rows = result.to_list()
# Scalar value
count = db.execute("MATCH (n) RETURN count(n)").scalar()
# Get nodes
nodes = db.execute("MATCH (n:Person) RETURN n").nodes()