Reputation: 193
I'm following a tutorial, and I'm using the last python2 (homebrew) with PyCharm (with project interpreter configured) - But I'm stuck in this part:
from py2neo import Graph, Node
graph = Graph()
nicole = Node("Person", name="Nicole")
graph.create(nicole)
graph.delete(nicole)
nicole = graph.merge_one("Person", "name", "Nicole")
Error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Graph' object has no attribute 'merge_one'
I already checked the documentation and it seems that I'm doing everything ok . I tried to uninstall and install last version of py2neo but with no success. How I solve this problem?
Expected behavior: Running that command from the python2 console: If that Person exists don't duplicate it but change its values, if don't exist create it.
Upvotes: 4
Views: 2628
Reputation: 193
I fastly ended up using the version 4 as opposed to 2. So using Graph.merge, solved the problem:
jonh = Node("Person", name="Jonh", age = 21)
graph.create(jonh)
ana = Node("Person", name="Ana", age = 44)
graph.create(ana)
michael = Node("Person", name="Ana", age = 33)
graph.merge(michael, "Person", "name") # So the age of Ana will change to 33, as expected.
For using the commands related to my question, the version 2 must be installed, for eg. directly from py2neo repo:
pip install https://github.com/technige/py2neo/archive/release/2.0.7.zip
Upvotes: 3
Reputation: 853
From inspecting the source code, I think the function you're looking for is Graph.match_one
. There is also a function Graph.merge
, but that doesn't take Node
as an argument.
Upvotes: 1