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