Neo4j py2neo 2.x,“;本地实体未绑定到远程实体“;

Neo4j py2neo 2.x,“;本地实体未绑定到远程实体“;,neo4j,py2neo,Neo4j,Py2neo,在将Neo4j和py2neo更新到最新版本(分别为2.2.3和2.0.7)时,我遇到了一些导入脚本的问题 例如,这里只需要一点代码 graph = py2neo.Graph() graph.bind("http://localhost:7474/db/data/") batch = py2neo.batch.PushBatch(graph) pp.pprint(batch) relationshipmap={} def create_go_term(line): if(line[6

在将Neo4j和py2neo更新到最新版本(分别为2.2.3和2.0.7)时,我遇到了一些导入脚本的问题

例如,这里只需要一点代码

graph = py2neo.Graph()
graph.bind("http://localhost:7474/db/data/")
batch = py2neo.batch.PushBatch(graph)

pp.pprint(batch)

relationshipmap={}

def create_go_term(line):
    if(line[6]=='1'):
        relationshipmap[line[0]]=line[1]
    goid = line[0]
    goacc = line[3]
    gotype = line[2]
    goname = line[1]

    term = py2neo.Node.cast( {
        "id": goid, "acc": goacc, "term_type": gotype, "name": goname
    })

    term.labels.add("GO_TERM")

    pp.pprint(term)

    term.push()
    #batch.append( term )

    return True


logging.info('creating terms')
reader = csv.reader(open(opts.termfile),delimiter="\t")
iter = 0
for row in reader:
    create_go_term(row)
    iter = iter + 1
    if ( iter > 5000 ):
        # batch.push()
        iter = 0

# batch.push()
当使用批处理或不使用批处理直接推送时,我遇到以下错误:

py2neo.error.BindError: Local entity is not bound to a remote entity
我做错了什么


谢谢

我认为您首先必须
创建
节点,然后才能添加标签并使用
推送

term = py2neo.Node.cast( {
    "id": goid, "acc": goacc, "term_type": gotype, "name": goname
})

graph.create(term) # now the node should be bound to a remote entity

term.labels.add("GO_TERM")

term.push()
或者,可以使用标签创建节点:

term = Node("GO_TERM", id=goid, acc=goacc, ...)
graph.create(term)

我认为您首先必须
创建
节点,然后才能添加标签并使用
推送

term = py2neo.Node.cast( {
    "id": goid, "acc": goacc, "term_type": gotype, "name": goname
})

graph.create(term) # now the node should be bound to a remote entity

term.labels.add("GO_TERM")

term.push()
或者,可以使用标签创建节点:

term = Node("GO_TERM", id=goid, acc=goacc, ...)
graph.create(term)

谢谢它创建节点。但是如果使用批处理(在代码中取消注释),它会逐个创建节点。您知道在这种情况下如何处理吗?您应该使用密码事务,而不是批处理:。看看密码任务。谢谢!它创建节点。但是如果使用批处理(在代码中取消注释),它会逐个创建节点。您知道在这种情况下如何处理吗?您应该使用密码事务,而不是批处理:。看看密码任务。