将Neo4j数据库转储转换为CSV文件,无需Neo4j企业服务器。

huangapple go评论48阅读模式
英文:

Convert Neo4j-Database-Dump Into CSV-File Without Neo4j-Enterprise-Server

问题

我能够将Neo4j数据库转储文件转换为CSV文件吗?

我创建了一个Neo4j-Docker容器 <br />,该容器基于Neo4j社区版(5.6.0)创建。<br /> 阅读Neo4j-Docs的导出到CSV。<br> 从ICIJ的Offshore-Leaks-Database获取了Neo4j数据库转储文件 <br> 在他们的GitHub OffshoreLeaks-Data-Packages上。<br> 导入到Neo4j-Docker容器的Neo4j-Community-Server中。

我正在寻找一种无需注册或购买Neo4j即可导出数据的方法。<br> 我只希望数据可以导入其他数据库和服务。<br> 你有什么方法可以导出这些数据吗?

我不能直接导出数据库,因为<br> Neo4j只允许Community-Edition-安装中有1个用户数据库。<br> 所以他们关于导出到CSV的文档在这里无法直接使用。<br>

英文:

How are you supposed to convert Neo4j-Database-Dumps into CSV-Files?

I've created a Neo4j-Docker-container <br />
Which is created from Neo4j Community Edition (5.6.0). <br />
Read the Neo4j-Docs's Export-to-CSV. <br>
Got a Neo4j-Database-Dump from ICIJ's Offshore-Leaks-Database <br>
On their GitHub OffshoreLeaks-Data-Packages. <br>
Imported on the Neo4j-Docker-container's Neo4j-Community-Server.

I'm looking for ways to export without needing to sign-up or purchase Neo4j. <br>
I just want the data to be importable to other databases and services. <br>
What are some ways you've come up with exporting the data?

I cannot export the database as-is, because <br>
Neo4j only allows 1 User-Database for Community-Edition-Installations. <br>
So their docs on Export-2-CSV don't work as-is here. <br>

答案1

得分: 0

我唯一使这个工作的方法是这样的。

步骤:

  1. 获取图数据库数据
  2. 根据需要重命名为.dump扩展名(参考文档
  3. 创建Neo4j-Docker容器(参考链接
     docker run -d \
        -p 7474:7474 -p 7687:7687 \
        -e apoc.export.file.enabled=true \
        -e apoc.import.file.enabled=true \
        -e apoc.import.file.use_neo4j_config=true \
        -e NEO4J_PLUGINS=["apoc"] \
        neo4j
    
  4. 创建Neo4j-Dumps目录
    1. 使用命令 winpty docker exec -it [neo4j_container] sh 进入容器
    2. 创建目录 mkdir /var/lib/neo4j/data/dumps
  5. 将数据导入Neo4j容器(参考文档
    docker cp [filename] [neo4j-container]:/var/lib/neo4j/data/dumps/
    
  6. 创建允许Neo4j-Dumps的apoc.conf文件
    1. 使用命令 winpty docker exec -it [neo4j_container] sh 进入容器
    2. 创建 apoc.conf 文件
      • touch /var/lib/neo4j/conf/apoc.conf
    3. 编辑 apoc.conf 文件
      • 使用CLI编辑器(参考链接
      • 或者使用Docker UI文件编辑器(右键单击文件进行编辑,参考链接
      apoc.export.file.enabled=true
      apoc.import.file.enabled=true
      apoc.import.file.use_neo4j_config=true
      dbms.security.procedures.unrestricted=apoc.*
      
      • 如果命令不起作用,需要添加此行
    4. 重新启动Neo4j容器以使更改生效
  7. 恢复数据库备份(参考文档
    bin/neo4j-admin database load [filename(不包含扩展名)] --overwrite-destination
    
  8. 将数据库备份迁移到Neo4j v5.X.X(参考文档
    bin/neo4j-admin database migrate [filename(不包含扩展名)] --force-btree-indexes-to-range
    
  9. 重新分配Neo4j允许的单用户数据库
    1. 编辑 neo4j.conf 文件
    2. 添加/取消注释
      • 文件名决定数据库名称
      initial.dbms.default_database=[filename(不包含扩展名)]
      
    3. 重新启动Neo4j容器以使更改生效
  10. 将Neo4j-Dump文件重命名为neo4j.dump
    • 因为只有Neo4j数据库允许APOC命令
    • 要么编辑文件名,要么重新添加
  11. 恢复数据库备份(参考文档
    bin/neo4j-admin database load neo4j --overwrite-destination
    
  12. 将数据库备份迁移到Neo4j v5.X.X(参考文档
    bin/neo4j-admin database migrate neo4j --force-btree-indexes-to-range
    
  13. 重新分配Neo4j允许的单用户数据库
    1. 编辑 neo4j.conf 文件
    2. 添加/取消注释
      initial.dbms.default_database=neo4j
      
    3. 重新启动Neo4j容器以使更改生效
  14. 恢复数据库备份
    CALL apoc.export.csv.all("filename.csv", {})
    
    1. 使用Neo4j Studio(网站)
    2. 使用命令行
      1. 进入Neo4j容器的Shell
      2. 执行命令 /var/lib/neo4j/bin/neo4j
  15. /var/lib/neo4j/import/neo4j.csv保存neo4j.csv
英文:

The only way I've gotten this to work is this.

Steps:

  1. Get Graph Database Data
  2. Rename to dump extension as needed
  3. Create Neo4j-Docker-Container
     docker run -d \
        -p 7474:7474 -p 7687:7687 \
        -e apoc.export.file.enabled=true \
        -e apoc.import.file.enabled=true \
        -e apoc.import.file.use_neo4j_config=true \
        -e NEO4J_PLUGINS=\[\&quot;apoc\&quot;\] \
        neo4j
    
  4. Create the Neo4j-Dumps Directory
    1. winpty docker exec -it [neo4j_container] sh
    2. mkdir /var/lib/neo4j/data/dumps
  5. Import Data into Neo4j-Container
    docker cp [filename] [neo4j-container]:/var/lib/neo4j/data/dumps/
    
  6. Create an apoc.conf that allows Neo4j-Dumps
    1. winpty docker exec -it [neo4j_container] sh
    2. Create apoc.conf
      • touch /var/lib/neo4j/conf/apoc.conf
    3. Add/Edit apoc.conf
      apoc.export.file.enabled=true
      apoc.import.file.enabled=true
      apoc.import.file.use_neo4j_config=true
      dbms.security.procedures.unrestricted=apoc.*
      
      • Needed if commands not working
    4. Restart Neo4j-Container to take affect
  7. Restore Database Dump
    bin/neo4j-admin database load [filename (no extension)] --overwrite-destination
    
  8. Migrate Database Dump to Neo4j v5.X.X
    bin/neo4j-admin database migrate [filename (no extension)] --force-btree-indexes-to-range
    
  9. Reassign the single User-Database that Neo4j allows
    1. Edit neo4j.conf
    2. Add / Uncomment-Edit
      • The filename decides the database name
      initial.dbms.default_database=[filename (no extension)]
      
    3. Restart Neo4j-Container to take affect
  10. Rename the Neo4j-Dump file as neo4j.dump
    • This is because only the Neo4j-Database is allowed APOC commands
    • Either edit the filename or readd
  11. Restore Database Dump
    bin/neo4j-admin database load neo4j --overwrite-destination
    
  12. Migrate Database Dump to Neo4j v5.X.X
    bin/neo4j-admin database migrate neo4j --force-btree-indexes-to-range
    
  13. Reassign the single User-Database that Neo4j allows
    1. Edit neo4j.conf
    2. Add / Uncomment-Edit
      initial.dbms.default_database=neo4j
      
    3. Restart Neo4j-Container to take affect
  14. Restore Database Dump
    CALL apoc.export.csv.all(&quot;filename.csv&quot;, {})
    
    1. Use the Neo4j Studio (Website)
    2. Use Command-Line
      1. Shell into the Neo4j-Container
      2. /var/lib/neo4j/bin/neo4j command
  15. Save neo4j.csv from /var/lib/neo4j/import/neo4j.csv

huangapple
  • 本文由 发表于 2023年4月6日 21:33:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/75950156.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定