Python Neo4J/py2neo——在事务中创建“关系”?
在交易之外,我可以这样做:Python Neo4J/py2neo——在事务中创建“关系”?,python,neo4j,py2neo,Python,Neo4j,Py2neo,在交易之外,我可以这样做: 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, 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()