i am try to create nodes and relationship to database by using python but it takes very too much time. I use official neo4j-driver library and connect to database by Bolt protocal.
from neo4j import GraphDatabase
driver = GraphDatabase.driver('bolt://localhost:7687', auth=(user, pass))
i write the program to create about 13,000 nodes and 642,000 relationship and it takes time about 12 hour.
session = driver.session()
def createNode(props):
Label = 'SINGLE_NODE'
return session.run("CREATE (a:"+Label+" {props}) "
"RETURN id(a)", {'props':props}).single().value()
def createRelation(n1,n2,props):
Label = 'SINGLE_NODE'
return session.run("MATCH (a:"+Label+"),(b:"+Label+")
WHERE id(a) = {n1} AND id(b) = {n2} "
"CREATE (a)-[rel:IS_CONNECTED {props}]->(b)
RETURN rel", {'n1':n1,'n2':n2,'props':props}).single().value()
before i using neo4j-driver i use to use py2neo but it a little more slower than neo4j-driver. So are there any suggestion to making program processing faster. thank you