py2neo - updating existing node with new properties w/uniqueness constraint (merge_one)

Two things;

1.) tweet.push() has been deprecated. The docs suggest using graph.push(tweet).

2.) I am having trouble to get this working with a transaction such as:

transaction = graph.begin()
transaction.merge(tweet)
transaction.graph.push(tweet)
transaction.commit()

Any suggestion on the difference between using graph.merge and transaction.merge?


py2neo v3 now has graph.merge(), which you can use to the same effect.

First find or create the node with graph.merge(), matching only on its unique property, then update its other non-unique properties with node.push(). You would've had to do the same thing with graph.merge_one(), just with a slightly different syntax.

from py2neo import Graph, Node
graph = Graph()

tweet = Node('Tweet', id=123)
graph.merge(tweet)
tweet['text'] = 'Hello World'
tweet.push()

I should update that twitter script to use py2neo v3; thanks for the reminder.