无法检索路由信息| Neo4j



我在VS Code中连接到我的Neo4j数据库有困难。

我从Neo4J文档中给出的模板代码开始:

from neo4j import GraphDatabase
import logging
from neo4j.exceptions import ServiceUnavailable
class Neo4jConnection:

def __init__(self, uri, user, pwd):
self.__uri = uri
self.__user = user
self.__pwd = pwd
self.__driver = None
try:
self.__driver = GraphDatabase.driver(self.__uri, auth=(self.__user, self.__pwd))
except Exception as e:
print("Failed to create the driver:", e)

def close(self):
if self.__driver is not None:
self.__driver.close()

def query(self, query, db=None):
assert self.__driver is not None, "Driver not initialized!"
session = None
response = None
try: 
session = self.__driver.session(database=db) if db is not None else self.__driver.session() 
response = list(session.run(query))
except Exception as e:
print("Query failed:", e)
finally: 
if session is not None:
session.close()
return response

然后连接到数据库:

conn = Neo4jConnection(uri="neo4j+s://7022d007.databases.neo4j.io", user="neo4j", pwd="****")

然后我尝试调用neo4j在数据库中运行一个任务:

query_string = '''
CALL db.schema.visualization()
'''
conn.query(query_string, db='MARA')

然后失败并给了我错误:无法检索路由信息查询失败:无法检索路由信息

这可能是由于证书错误。在将证书更改为自签名SSL后,它对我有效。您可以尝试使用neo4j+ssc://{IP_address}:{Port}作为到DB的链接。

最新更新