python - Connecting to Neo4j database after importing CSV
问题描述
I have imported my csv files using the neo4j-admin according to the documentation using the following command
/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
the result looks like
IMPORT DONE in 15s 997ms.
Imported:
19354 nodes
11759454 relationships
58062 properties
Peak memory usage: 1.03 GB
and I can see a file called graph.db
in the data/databases
folder.
I go to python and do:
from py2neo import Graph, Node, Relationship, Database
%matplotlib inline
%load_ext cypher
default_db = Database(db = Database())
graph = Graph("bolt://localhost:3637")
and after running my query I get the following:
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'))
I guess I am not doing the connection correctly within Python and didn't find anywhere in the documentation how to do it. Basically, I have not set any password, username and even don't the port. I generated a report using neo4j-admin report
and there was not anything relevant either. therefore, I appreciate your comments on how I can build the connection and start querying from 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笔记本......
推荐阅读
- c++ - C++ | DLL / EXE - 如何从导出的类中调用另一个类方法?
- php - 基于当前值的for循环步骤
- php - GnuTLS recv 错误(-54):拉函数中的错误
- python - 根据第一列中的模式变化在熊猫数据框中创建新列
- r - 在 r 中的 geom_net 中标记边缘
- javascript - 如何旋转图像.onclick
- rest - 打开附加到数据库的 REST API - 什么可以阻止不良行为者向我的数据库发送垃圾邮件?
- karate - 如何在类路径中使用嵌入式表达式
- python - 进程不能同时执行超过 3 个函数
- python - 如何在变量已经定义后更改其数值?