Skip to content

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.

for row in result:
    print(row['column_name'])

getitem()

Access a row by index.

row = result[0]

len()

Get the number of rows in the result.

count = len(result)

to_list()

Convert to list of dicts.

def to_list(self) -> List[Dict[str, Any]]

scalar()

Return the first column of the first row as a scalar value.

def scalar(self) -> Any

nodes()

Return all nodes from the result.

def nodes(self) -> List[Node]

edges()

Return all edges from the result.

def edges(self) -> List[Edge]

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()