当前位置:   article > 正文

py2neo连接neo4j demo_py2neo 2021.2.3

py2neo 2021.2.3
#pip install py2neo
#py2neo==2021.2.3
  • 1
  • 2
from py2neo import Graph, Node, Relationship

# 连接Neo4j

g = Graph("http://localhost:7474", auth=("neo4j", "neo4j"))
# 旧的连接方式
# g = Graph(
#     host='127.0.0.1',
#     http_port='7474',
#     user='neo4j',
#     password='neo4j')

# 创建节点
da_vinci = Node('person', name='DA VINCI')
mona_lisa = Node('art', name='MONA LISA')
louvre = Node('place', name='LOUVRE')

g.create(da_vinci)
g.create(mona_lisa)
g.create(louvre)

relation1 = Relationship(da_vinci, 'painted', mona_lisa)
relation2 = Relationship(mona_lisa, 'is_in', louvre)

g.create(relation1)
g.create(relation2)

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27

在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/161134?site
推荐阅读
相关标签
  

闽ICP备14008679号