简体   繁体   English

Py2neo 更新现有节点

[英]Py2neo updateing existing node

I've been trying to update an existing node using py2neo.我一直在尝试使用 py2neo 更新现有节点。 Some things worth metionioning:一些值得一提的事情:

OS: Arch Linux x86_64
python version: 3.8
py2neo version: 2021.0.1
ne4j version: 4.2.1
flask version: 1.1.2
Application is running inside a docker container, the actual flask website is on port 5000, neo4j interface is on port 7474 and flask connects to port 7687 (neo4j)

Here are a few methods I've tried:以下是我尝试过的几种方法:

1) 1)

def update_node(self, node_name: str, node_group: str, property_update: dict):
    return self.name_search_person(node_name=node_name, node_group=node_group).update(**property_update)
def update_node(self, node_name: str, node_group: str, property_update: dict):
        node_to_update = self.name_search_person(node_name=node_name, node_group=node_group)
        if node_to_update:
            node_to_update.update(**property_update)
            self.g.push(node_to_update)
        del node_to_update
        return 'successfully updated node'

At the 2nd method I've tried with the following function calls:在第二种方法中,我尝试了以下 function 调用:

graph_db.update_node(node_name='Andrei', node_group='Person', property_update={'name': t['Updated']})

(this just returns NameErrror: name 't' is not defined (I've seen this Here ) (这只是返回 NameError: name 't' is not defined(我在这里看到过)

and

graph_db.update_node(node_name='Andrei', node_group='Person', property_update={'name':'Updated'})

Am I doing something wrong with the function calls or is the actual updating function not working by some reason?我对 function 调用做错了什么,还是实际更新 function 由于某种原因无法正常工作?

Apparently the solution was to just remove the 't' from the function call显然解决方案是从 function 调用中删除“t”

graph_db.update_node(node_name='Andrei', node_group='Person', property_update={'name': t['Updated']}

so now it's:所以现在是:

graph_db.update_node(node_name='Andrei', node_group='Person', property_update={'name': ['Updated']}

Honestly IDK why it didn't work with the other function call老实说 IDK 为什么它不能与其他 function 通话一起使用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM