0

I pulled and run neo4j docker:

sudo docker run -p7474:7474 -p7687:7687 -e NEO4J_AUTH=neo4j/s3cr3t neo4j

From python I can connect to it with:

scheme = "neo4j"
host_name = "localhost"
port = 7687
url = "{scheme}://{host_name}:{port}".format(scheme=scheme, host_name=host_name, port=port)
user = "neo4j"
password = "s3cr3t"
driver = GraphDatabase.driver(url, auth=(user, password))

But it seems that there is no API to choose the DB name I want to work with ?

  • Is it possible to create multiple databases (like postgres psycopg2 connect function with dbname ?)

  • I want to be able to create 2 different DBs (graphs) and to choose the DB (graph) to work with through python

  • How can I do it ?

cybersam
  • 63,203
  • 6
  • 53
  • 76
Boom
  • 1,145
  • 18
  • 44

1 Answers1

1

To connect to a specific database, you can pass the database's name as the value of the database keyword argument when you create the Session used for your transactions.

For example, to create a Session for the database named "foo":

...
driver = GraphDatabase.driver(uri, auth=(user, password))
session = driver.session(database="foo")
...
cybersam
  • 63,203
  • 6
  • 53
  • 76