【问题标题】:Unable to connect NEO4J using neo4j python driver无法使用 neo4j python 驱动程序连接 NEO4J
【发布时间】:2022-12-07 01:02:26
【问题描述】:

我无法使用 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)

感谢您帮助解决问题。

我通过下面的 sn-p 连接

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)

【问题讨论】:

    标签: python python-3.x neo4j cypher neo4j-python-driver


    【解决方案1】:

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

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

    【讨论】:

    • 嗨 Gonzalo,我错过了更新连接脚本。现在我已经添加了我的问题,这与你的代码几乎相同,我已经尝试使用 encrypted=False 但这无助于解决问题
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-12
    相关资源
    最近更新 更多