You can use Bulbs (http://bulbflow.com) to connect to Neo4j Server from Python.
#!/usr/bin/env python
"""
Simple example showing node and relationship creation plus
execution of Cypher queries
"""
from __future__ import print_function
# Import Neo4j modules
from py2neo import neo4j, cypher
# Attach to the graph db instance
graph_db = neo4j.GraphDatabaseService("http://localhost:7474/db/data/")
# Create two nodes
node_a, node_b = graph_db.create_nodes(
{"name": "Alice"},
{"name": "Bob"}
)
# Join the nodes with a relationship
rel_ab = node_a.create_relationship_to(node_b, "KNOWS")
# Build a Cypher query
query = "START a=node({}) MATCH a-[:KNOWS]->b RETURN a,b".format(node_a.id)
# Define a row handler...
def print_row(row):
a, b = row
print(a["name"] + " knows " + b["name"])
# ...and execute the query
cypher.execute(query, graph_db, row_handler=print_row)
---for
rel in self.db.relationships:print 'date:', rel['date']
The results are:
java 2sec
python 25sec
py2neo 131sec
Hi,Thanks for the feedback.I boiled it down to a very simple test on a graph with 1e5 edges- just looping over each Relationship and getting some property. I tested it with python bindings (JPype), java and with py2neo rest interface using callbacks. In python the basic loop is this:for
rel in self.db.relationships:print 'date:', rel['date']
The results are:
java 2sec
python 25sec
py2neo 131sec