cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Specify database in py2neo with Neo 4.0

When using the newest version of py2neo with Neo 4.0.2 is there any way to specify that you want to connect to the non-default database?

e.g. I only have one Neo server and I want to have a 'dev' and a 'prod' graph on the same machine.

If this isn't possible with py2neo how do I accomplish this with any of the python drivers?

7 REPLIES 7

I'd love to switch database or connect to specific ones for specific queries or based on the current logged in user to apply multiple tenant that are actually separated. Couldn't find it in the driver docs so i hope Py2Neo has something planned. @technige do you know about this?

I have the same need. So far I haven't been able to connect to any other database, except the default. This is very frustating...

The 4.0 python drivers have not been release yet so you will only be able to connect to the default database.

If you want to connect to a different database, you can set that different database as the default in neo4j.conf and then restart the Neo4j instance.

Elaine

Thank you for the clarification Elaine! Had the same exact question over here. We'll switch the default database on an as needed basis. Hope this will be addressed in py2neo in the near future.

The latest py2neo v5 pre-release adds support for multiple databases. There are some details in the docs here:

https://py2neo.org/v5/database.html#py2neo.database.Graph

Can confirm that technige's recommendation works. Adding 'name' in the graph database connector populates the specified graph and overrides the default setting.

from py2neo import Graph >>> sales = Graph("bolt+s://g.example.com:7687", name="target db")

awesome. you made my day