0

I'm having difficulties connecting to my Neo4j Database in VS Code.

I started with the boiler plate code that is given on the Neo4J documentation:

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

Then I connected to my database:

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

Then I attempted to call for neo4j to run a task in the database:

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

Which then failed and gave me the error: Unable to retrieve routing information Query failed: Unable to retrieve routing information

Owen
  • 178
  • 2
  • 7
  • looks like you are using aura neoj4 database; can you connect to your aura db using the browser? – jose_bacoy Jul 18 '22 at 18:47
  • Aura does not offer multi-DB as far as I know. Therefore, you cannot configure a custom DB like you're doing here with 'MARA'. – fbiville Jul 19 '22 at 09:27

1 Answers1

2

This could be due to the certificate error. It worked for me after changing the certificate to self signed SSL. You could try using neo4j+ssc://{IP_address}:{Port} as the link to DB.

  • @CapiHidalgo While this may solve the connection issue, the usage of neo4j+ssc might not be secure. For more details see https://github.com/neo4j/neo4j-python-driver/issues/628#issuecomment-1219119173 – user7358743 Oct 06 '22 at 17:27
  • Thank you so much for your answer.You are completely right and finally I was able to solve my problem by installing the certificates based on this post https://stackoverflow.com/questions/52805115/certificate-verify-failed-unable-to-get-local-issuer-certificate and it solved my issue. Again thanks! – Capi Hidalgo Oct 09 '22 at 18:24