Python
Nexyron runs inside your Python process. No server, no connection string, no network hop.
Opening a database
import nexyron
db = nexyron.open("./business.nexyron")
result = db.query("MATCH (c:Customer) RETURN count(c) AS customers")
for row in result:
print(row["customers"])
db.close()
Use a context manager so the database is closed even if something raises:
with nexyron.open("./business.nexyron") as db:
for row in db.query("MATCH (s:Site) RETURN s.name AS name ORDER BY name"):
print(row["name"])
Parameters
Pass values as parameters. Never build query text by concatenating them: it is slower, because the query cannot be reused, and it is how injection bugs happen.
rows = db.query(
"""
MATCH (c:Customer)-[:BELONGS_TO]->(s:Site {name: $site})
WHERE c.joined_at >= $since
RETURN element_id(c) AS id, c.name AS name
ORDER BY c.name
""",
{"site": "Bergen", "since": "2026-01-01"},
)
Writing
db.query(
"CREATE (c:Customer {name: $name, joined_at: $joined})",
{"name": "Nora Ellingsen", "joined": "2026-08-01"},
)
Group related changes into a transaction so they commit or fail together:
with db.transaction() as tx:
tx.query("CREATE (s:Site {name: $name})", {"name": "Trondheim"})
tx.query(
"""
MATCH (c:Customer {name: $customer}), (s:Site {name: $site})
CREATE (c)-[:BELONGS_TO]->(s)
""",
{"customer": "Nora Ellingsen", "site": "Trondheim"},
)
If the block raises, nothing is committed.
Reading results
Rows behave like dictionaries keyed by the names you returned. Return exactly the fields you need rather than whole subjects: it keeps the result small and the shape stable as the model grows.
rows = list(db.query("""
MATCH (c:Customer)
RETURN element_id(c) AS id, c.name AS name, c.revenue AS revenue
ORDER BY revenue DESC
LIMIT 20
"""))
total = sum(r["revenue"] for r in rows)
Analytics in the query
Graph algorithms and analytical procedures are called from Cypher, so heavy work stays in the engine rather than being pulled into Python:
rows = db.query("""
CALL nexyron.pagerank() YIELD node_id, score
RETURN node_id, score
ORDER BY score DESC
LIMIT 10
""")
The full set is in the Cypher reference.
Working with pandas
Results are plain rows, so a DataFrame is one call away when you want one:
import pandas as pd
df = pd.DataFrame(db.query("""
MATCH (s:Site)<-[:BELONGS_TO]-(c:Customer)
RETURN s.name AS site, count(c) AS customers
ORDER BY customers DESC
"""))
Do the aggregation in Cypher rather than in pandas where you can. The engine is built for it, and moving less data is faster than moving more.