簡體   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