当前位置:网站首页>py2neo基本语法
py2neo基本语法
2022-06-27 04:35:00 【思想在拧紧】
1. 导入库
import py2neo
from py2neo import Graph,Node,Relationship,NodeMatcher
2. 连接neo4j
graph_ = Graph("http://localhost:7474", auth=("username", "password"))
# g = Graph('http://username:[email protected]:7474') 可以
# 下面这种写法,py2neo-2021.2.3不支持。
# graph = Graph('http://127.0.0.1:7474', username="your_username", password="your_password")
3. 创建节点、关系
方法一:导入txt或csv文件至neo4j
参考:知识图谱实战:构建红楼梦知识图谱_任菜菜学编程的博客-CSDN博客
在jupyter中创建的txt文件可以直接导入
如果是csv文件,则建议用记事本打开,另存为
bom-utf-8格式的csv文件
方法二:使用py2neo中的语法
参考:py2neo——Neo4j&python的配合使用 - 简书 (jianshu.com)
4. 执行cypher命令
建议在创建节点前删除已有的所有节点,避免查询混乱
# 删除数据库所有节点和关系
graph_.run('MATCH (n) detach delete n')
# 查看数据库所有节点和关系
MATCH (n) RETURN n
边栏推荐
- 019 C语言基础:C预处理
- WPF 开源控件库Extended WPF Toolkit介绍(经典)
- Cache comprehensive project - seckill architecture
- [C language] keyword supplement
- Kotlin compose compositionlocalof and staticcompositionlocalof
- WPF open source control library extended WPF toolkit Introduction (Classic)
- Mobilenet series (4): mobilenetv3 network details
- 1.5 use of CONDA
- A^2=e | the solution of the equation | what exactly can this equation tell us
- Common programming abbreviations for orbit attitude
猜你喜欢

Deep dive kotlin synergy (XV): Test kotlin synergy

真xx相来了?测试/开发程序员为什么不愿意加班,这是个疯狂的状态......

IOS development: understanding of dynamic library shared cache (dyld)

Log collection system

Microservice system design -- microservice invocation design

基于MobileNet-Yolov4搭建轻量化目标检测

微服务系统设计——统一鉴权服务设计

Why does C throw exceptions when accessing null fields?

系统架构设计——互联网金融的架构设计

Is the truth XX coming? Why are test / development programmers unwilling to work overtime? This is a crazy state
随机推荐
Microservice system design -- distributed cache service design
缓存综合项目--秒杀架构
016 C language foundation: C language enumeration type
Kotlin compose implicitly passes the parameter compositionlocalprovider
Laptop does not have WiFi option solution
Ledrui ldr6035 usb-c interface device supports rechargeable OTG data transmission scheme.
日志收集系统
011 C language basics: C scope rules
渗透测试-文件上传/下载/包含
Microservice system design -- distributed transaction service design
012 C语言基础:C数组
MATLAB | 基于分块图布局的三纵坐标图绘制
The most detailed download tutorial of MySQL
文旅灯光秀打破时空限制,展现景区夜游魅力
math_ Number set (number set symbol) and set theory
021 basics of C language: recursion, variable parameters
Mysql database foundation: DQL data query language
系统架构设计——互联网金融的架构设计
015 C语言基础:C结构体、共用体
019 C语言基础:C预处理