使用py2neo 2.0在neo4j中批量插入

时间:2015-03-25 10:59:44

标签: neo4j batch-processing labels py2neo

我已经编写了这个函数来批量插入数据但是在添加标签时我得到BindError:本地实体没有绑定到远程实体。

def bulkInsertNodes(n=1000):
    graph = Graph()
    btch = WriteBatch(graph)
    nodesList = []
    for i in range(1,n+1):
        temp = Node(id = str(i))
        nodesList.append(temp)
        btch.create(temp)
    btch.run()

    btch = WriteBatch(graph)
    for n in nodesList:
        btch.add_labels(n,"Person")
    btch.run()

0 个答案:

没有答案