【发布时间】: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