导入数据到neo4j数据库

首先去MySQL端通过SQL把数据导出 .csv 格式的文件。

记得去掉 .csv 数据文件里数据上的引号。

sed -i 's/"//g' 1.csv

 

然后把 .csv 数据文件放到 import 目录里:/data/neo4j/neo4j-community-4.4.10/import/

 

登录客户端

/usr/local/jdk-11.0.16.1/bin/java -jar /data/neo4j/neo4j-community-4.4.10/bin/tools/cypher-shell.jar

输入账号/密码,默认是 neo4j/neo4j。

load csv with headers from 'file:///1.csv' as line match (s:WhStudent {student_id:toInteger(line.student_id)}) ,(p:WhArticle{article_id:toInteger(line.attr_id) }) where s.student_id = toInteger(line.student_id) and p.article_id = toInteger(line.attr_id)  merge (s)-[r:Like{created_at:toInteger(line.created_at),updated_at:toInteger(line.updated_at),is_vest:toInteger(line.is_vest)}]->(p);

 

posted @ 2022-09-29 11:18  捧花大王  阅读(127)  评论(0编辑  收藏  举报