簡體   English   中英

導入 CSV 后連接到 Neo4j 數據庫

[英]Connecting to Neo4j database after importing CSV

我已經根據 文檔使用以下命令使用 neo4j-admin 導入了我的 csv 文件

/bin/neo4j-admin import --mode=csv --nodes all_nodes_ne_header.csv,all_nodes_ne.csv --relationships all_relations_ne_header.csv,all_relations_ne.csv

結果看起來像

IMPORT DONE in 15s 997ms.
Imported:
  19354 nodes
  11759454 relationships
  58062 properties
Peak memory usage: 1.03 GB

我可以在data/databases文件夾中看到一個名為graph.db的文件。

我去 python 並執行以下操作:

from py2neo import Graph, Node, Relationship, Database
%matplotlib inline
%load_ext cypher

default_db = Database(db = Database())
graph = Graph("bolt://localhost:3637")

運行我的查詢后,我得到以下信息:

Format: (http|https)://username:password@hostname:port/db/name
...
ConnectionError: HTTPConnectionPool(host='localhost', port=7474): Max retries exceeded with url: /db/data/ (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x12e269790>: Failed to establish a new connection: [Errno 61] Connection refused'))

我想我沒有在 Python 中正確地進行連接,也沒有在文檔中的任何地方找到如何做到這一點。 基本上,我沒有設置任何密碼、用戶名,甚至沒有設置端口。 我使用neo4j-admin report生成了一份neo4j-admin report ,但也沒有任何相關內容。 因此,我感謝您對我如何建立連接並從 python 開始查詢的評論。

必須到配置文件並在neo4j.config編輯以下行

# The name of the database to mount
dbms.active_database=graph.db

然后可以運行./bin/neo4j consol

輸出應該像

Starting Neo4j.
2019-12-01 23:42:14.731+0000 INFO  ======== Neo4j 3.5.3 ========
2019-12-01 23:42:14.743+0000 INFO  Starting...
2019-12-01 23:42:16.599+0000 INFO  Bolt enabled on 127.0.0.1:7687.
2019-12-01 23:42:18.122+0000 INFO  Started.
2019-12-01 23:42:19.065+0000 INFO  Remote interface available at http://localhost:7474/

然后回到 jupyter notebook ...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM