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 | Number of rows scanned during query execution |
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()