繁体   English   中英

无法使用 neo4j python 驱动程序连接 NEO4J

[英]Unable to connect NEO4J using neo4j python driver

我无法使用 neo4j-python-driver 5.3.0 版连接到 Neo4j。 要求是使用 Neo4j python 驱动程序使用密码查询来查询 NEO4J DB。 即使数据库已启动并正在运行,它也会出现无法连接到服务器的错误,我可以通过 NEO4J Desktop 登录和使用。 低于错误

neo4j.exceptions.ServiceUnavailable: Couldn't connect to <URI>:7687 (resolved to ()):
[SSLCertVerificationError] Connection Failed. Please ensure that your database is listening on the correct host and port and that you have enabled encryption if required. Note that the default encryption setting has changed in Neo4j 4.0. See the docs for more information. Failed to establish encrypted connection. (code 1: Operation not permitted)

注意:URI 隐藏在上面的错误中。

我已将例外添加到 Ignores certificate verification issue,但它不会解决问题。

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

感谢您帮助解决问题。

我通过下面的片段连接

from neo4j import GraphDatabase
import urllib3

#Ignores certificate verification issue
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)


# Initialize connection to database
driver = GraphDatabase.driver('bolt+s://<URI>:7687', auth=(',username', '<password'))


query = 'match (n:Event{name:"test"}) return n'

#Run Cypher query
with driver.session() as session:
    info = session.run(query)
    for item in info:
        print(item)

无法知道您是如何连接的,但我们可以:

from neo4j import GraphDatabase
address="bolt://localhost:7687"
auth=('neo4j', "password")
driver = GraphDatabase.driver(address, auth=auth, encrypted=False)
....

你试过py2neo吗? 我在下面使用 dev 在 docker 中运行,prod 运行 Aura。

from py2neo import Graph
self.graph = Graph(os.getenv('DB_URI'), auth=(
            os.getenv('DB_USER'), os.getenv('DB_PASS')))

DB_URI 在开发上是“neo4j://0.0.0.0:7687”,在产品上是“neo4j+s://xxxx”

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM