from neo4j import GraphDatabase
driver = GraphDatabase.driver("bolt://localhost:7687", auth=("neo4j", "password"))
with driver.session() as session:
result = session.run("SHOW DATABASES")
print(result)
the result is <neo4j.work.result.Result object at 0x0000028F2BB30208>
How to get database names?
This will show you only the DATABASES names in cypher-shell:
SHOW DATABASES yield name;
Example from python:
test.py
from neo4j import GraphDatabase
driver = GraphDatabase.driver("bolt://localhost:7687", auth=("neo4j", "password"))
with driver.session() as session:
result = session.run("SHOW DATABASES yield name;")
for line in result:
print(line['name'])
When executed:
python test.py
neo4j
system
Tested in neo4j 4.2.1 , openjdk 11.0.15 2022-04-19 , python 3.7.0 , Ubuntu 20.04.4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With