学习记录py2neoNeo4j数据库的python驱动[数据库教程]
安装:
- 直接在命令行
pip3 install py2neo
- 官网下载(解压后放到python下的scripts中,在py2neo目录下cmd,输入python setup.py install
链接
auth=(用户名,密码)
from py2neo import Graph,Node,Relationshipgraph = Graph("http://localhost:7474",auth=("neo4j","password"))
问题:unauthorized(self.uri.string)
解决方法:
from py2neo import authenticate,Graph
authenticate("localhost:7474","账号","密码")
graph = Graph("http://localhost:7474/db/data")
创建节点和关系
(已通过batch-import导入,这步省略
a = Node("Person", name="Alice")b = Node("Person", name="Bob")
ab = Relationship(a, "KNOWS", b)
graph.create(ab)
查询
查询节点(使用原生查询语句
from py2neo import authenticate,Graphgraph = Graph("http://localhost:7474",auth=("neo4j","password"))
str = "match (变量名a:标签名{属性名:特定属性值}) return a"
x = graph.run(str).data()
y = pd.DataFrame(x)
学习记录-py2neo:Neo4j数据库的python驱动
原文:https://www.cnblogs.com/l999q/p/13396022.html
以上是 学习记录py2neoNeo4j数据库的python驱动[数据库教程] 的全部内容, 来源链接: utcz.com/z/534957.html