Say I have two Neo4j databases in a project and I need to switch back and forth between them. Currently, on the desktop application, I open and close the databases manually and re-run:
I have tried the following with a TEST_DB that I created in Neo4j desktop:
uri = "neo4j://localhost:7687"
driver = GraphDatabase.driver(uri, auth=("neo4j", "password"))
with driver.session(database="TEST_DB") as session:
cypher = '''
MATCH (n) -[r:CITES]-> (m)
RETURN n, r, m
'''
output = session.run(cypher).data()
print(output)
As well as:
uri = "neo4j://localhost:7687"
driver = GraphDatabase.driver(uri, auth=("neo4j", "password"))
session = driver.session(database="TEST_DB")
cypher = '''
MATCH (n) -[r:CITES]-> (m)
RETURN n, r, m
'''
result = session.run(cypher).data()
print(result)
session.close()
driver.close()
Both return an error:
ClientError: {code: Neo.ClientError.Database.DatabaseNotFound} {message: Unable to get a routing table for database 'TEST_DB' because this database does not exist}
What you see in your Neo4j Desktop with 3 dots, a start and stop big blue buttons is not a database, it's a DBMS, database(s) management system.
I would suggest you updating your Neo4j desktop app and then create a local DBMS version 4.2.2 and then read about database administration and the USE clause.