当前位置:网站首页>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
边栏推荐
- 第1章 绪论
- 微服务系统设计——微服务监控与系统资源监控设计
- 【B站UP DR_CAN学习笔记】Kalman滤波1
- Is the truth XX coming? Why are test / development programmers unwilling to work overtime? This is a crazy state
- PostgreSQL基础命令教程:创建新用户admin来访问PostgreSQL
- 办公室VR黄片,骚操作!微软HoloLens之父辞职!
- Chapter 1 Introduction
- ERP demand and sales management Kingdee
- 2022-06-26: what does the following golang code output? A:true; B:false; C: Compilation error. package main import “fmt“ func main() { type
- The most detailed download tutorial of MySQL
猜你喜欢

Why does C throw exceptions when accessing null fields?

文旅夜游|以沉浸式视觉体验激发游客的热情

日志收集系統

QChart笔记2: 添加鼠标悬停显示

【B站UP DR_CAN学习笔记】Kalman滤波3

MySQL development environment

ERP demand and sales management Kingdee

Fplan powerplan instance

清华大学开源软件镜像站网址

Matlab | drawing of three ordinate diagram based on block diagram layout
随机推荐
math_数集(数集符号)和集合论
Fplan power planning
【B站UP DR_CAN学习笔记】Kalman滤波1
微服务系统设计——微服务监控与系统资源监控设计
007 basics of C language: C operator
How to make ef core 6 support dateonly type
QChart笔记2: 添加鼠标悬停显示
Système de collecte des journaux
018 C语言基础:C文件读写
013 basics of C language: C pointer
MySQL development environment
010 C语言基础:C函数
733. image rendering
微服务系统设计——服务链路跟踪设计
nignx配置单ip限流
从某种意义来讲,互联网业已成为了一个孵化器,一个母体
Baidu PaddlePaddle's "universal gravitation" first stop in 2022 landed in Suzhou, comprehensively launching the SME empowerment plan
Nignx configuring single IP current limiting
MATLAB | 基于分块图布局的三纵坐标图绘制
Fplan powerplan instance