【问题标题】:Unable to retrieve routing information | Neo4j无法检索路由信息 | Neo4j
【发布时间】:2022-08-17 07:09:22
【问题描述】:

我在 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\')

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

  • 看起来您正在使用 aura neo4j 数据库;您可以使用浏览器连接到您的 aura db 吗?
  • 据我所知,Aura 不提供多数据库。因此,您不能像在此处使用“MARA”那样配置自定义数据库。

标签: python neo4j cypher


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-08-28
    • 2013-05-22
    • 1970-01-01
    • 2018-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多