python +neo4j
时间: 2023-08-29 20:05:04 浏览: 167
回答: Python可以通过两种方式操作Neo4j图数据库。一种方式是使用neo4j模块执行CQL(cypher)语句,另一种方式是使用py2neo模块通过操作Python变量来操作Neo4j。 在py2neo模块中,节点和关系是两个重要的数据结构,可以使用Node和Relationship类来创建节点和关系。例如,可以使用以下代码创建节点和关系: from py2neo import Graph,Node, Relationship a = Node('Person', name='fengling') b = Node('Person', name='yingying') r = Relationship(a, 'KNOWS', b) print(a, b, r) [2 除了使用py2neo模块来操作节点和关系,还可以使用Graph类来创建图并执行CQL语句。例如,可以使用以下代码创建图并执行CQL语句: from py2neo import Graph test_graph = Graph('http://localhost:7474',username='neo4j',password='test') a = Node('yule',name='谢娜') test_graph.create(a) b = Node('yule',name='张杰') test_graph.create(b) r = Relationship(a,'夫妻',b) test_graph.create(r) [3<em>1</em><em>2</em><em>3</em>
#### 引用[.reference_title]
- *1* [Python操作Neo4j图数据库的两种方式](https://blog.csdn.net/qq_46092061/article/details/121257719)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}} ] [.reference_item]
- *2* *3* [python操作neo4j](https://blog.csdn.net/yangfengling1023/article/details/82049715)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}} ] [.reference_item]
[ .reference_list ]
阅读全文
相关推荐

















