簡體   English   中英

Neo4J / py2neo - 在交易中創建“關系”?

[英]Neo4J / py2neo — create `Relationship` in transaction?

在交易之外,我可以這樣做:

from py2neo import Graph, Node, Relationship
graph = Graph()
graph.create(Relationship(node1, "LINKS_TO", node2))

我可以在交易中做類似的事嗎?:

tx = graph.cypher.begin()
tx.append(Relationship(node1, "LINKS_TO", node2))  # This doesn't work

或者我是否必須手動將其寫為密碼查詢?

好的,我知道了。

from py2neo import Graph, Relationship
from py2neo.cypher import CreateStatement

graph = Graph()
tx = graph.cypher.begin()

statement = CreateStatement(graph)
statement.create(Relationship(node1, "LINKS_TO", node2))
tx.append(statement)

tx.commit()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM