Skip to content

Your first query

This page builds the same two-person graph three ways. Each one uses an in-memory namespace (memory://), so nothing is written to disk and there is nothing to clean up. Swap the URI for file://… or s3://… when you want the data to persist — see Storage URIs.

Terminal window
pip install namidb
import namidb
db = namidb.Client("memory://demo")
db.cypher("CREATE (:Person {name: 'Alice', age: 30})")
db.cypher("CREATE (:Person {name: 'Bob', age: 25})")
db.cypher("""
MATCH (a:Person {name: 'Alice'}), (b:Person {name: 'Bob'})
CREATE (a)-[:KNOWS {since: 2020}]->(b)
""")
rows = db.cypher(
"MATCH (p:Person) WHERE p.age >= $min "
"RETURN p.name AS name, p.age AS age ORDER BY name",
params={"min": 18},
).rows()
print(rows)
# [{'name': 'Alice', 'age': 30}, {'name': 'Bob', 'age': 25}]
friends = db.cypher(
"MATCH (a:Person)-[k:KNOWS]->(b:Person) "
"RETURN a.name AS a, b.name AS b, k.since AS since"
).rows()
print(friends)
# [{'a': 'Alice', 'b': 'Bob', 'since': 2020}]

Each write is durable when cypher() returns. Any result converts to a DataFrame with .to_pandas(), .to_polars() or .to_arrow().

Next steps