简体   繁体   English

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

[英]Unable to connect NEO4J using neo4j python driver

I'm unable to connect to Neo4j using neo4j-python-driver version 5.3.0.我无法使用 neo4j-python-driver 5.3.0 版连接到 Neo4j。 Requirement is using Neo4j python driver to query NEO4J DB using cypher queries.要求是使用 Neo4j python 驱动程序使用密码查询来查询 NEO4J DB。 It gives the error failed to connect to server even when the database is up and running and i can able to login and use through NEO4J Desktop.即使数据库已启动并正在运行,它也会出现无法连接到服务器的错误,我可以通过 NEO4J Desktop 登录和使用。 Getting below error低于错误

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)

Note: URI hided in the above error.注意:URI 隐藏在上面的错误中。

I have added the exception to Ignores certificate verification issue, but it won't solve the issue.我已将例外添加到 Ignores certificate verification issue,但它不会解决问题。

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

Appreciate your help to resolve the issue.感谢您帮助解决问题。

i'm connecting via below snippet我通过下面的片段连接

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)

No way to know how you are connecting, but we do:无法知道您是如何连接的,但我们可以:

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

Have you tried py2neo?你试过py2neo吗? I use below with dev running in docker and prod running Aura.我在下面使用 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 is 'neo4j://0.0.0.0:7687' on dev and 'neo4j+s://xxxx' on prod 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