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.

Connecting 1 specific database out multiple database with python

shubham
Node Clone

hii Everyone,
we have created a graph and there are three database running in it ,and if i am trying to connect it with python using py2neo then it connecting to default database, so if we want to select 1 out of 3 database ,is there anyway using py2neo and any python to neo4j connector(neo4j driver).

1 ACCEPTED SOLUTION

webtic
Graph Fellow

Hi there,

Make sure you use the v5 version of py2neo; multi database support as found in Neo4J 4 is not supported in v4 of py2neo. In v5 it is supported via the name= parameter in the Graph object.

https://py2neo.org/v5/database.html#the-graph

class py2neo.database.Graph(uri, name=None, **settings)[source]
The Graph class represents the graph data storage space within a Neo4j graph database. Connection details are provided using URIs and/or individual settings.

The name argument allows selection of a graph database by name. When working with Neo4j 4.0 and above, this can be any name defined in the system catalogue, a full list of which can be obtained through the Cypher SHOW DATABASES command. Passing None here will select the default database, as defined on the server. For earlier versions of Neo4j, the name must be set to None.

View solution in original post

4 REPLIES 4

webtic
Graph Fellow

Hi there,

Make sure you use the v5 version of py2neo; multi database support as found in Neo4J 4 is not supported in v4 of py2neo. In v5 it is supported via the name= parameter in the Graph object.

https://py2neo.org/v5/database.html#the-graph

class py2neo.database.Graph(uri, name=None, **settings)[source]
The Graph class represents the graph data storage space within a Neo4j graph database. Connection details are provided using URIs and/or individual settings.

The name argument allows selection of a graph database by name. When working with Neo4j 4.0 and above, this can be any name defined in the system catalogue, a full list of which can be obtained through the Cypher SHOW DATABASES command. Passing None here will select the default database, as defined on the server. For earlier versions of Neo4j, the name must be set to None.

Hi Paul,

I followed what you said and tried it out when I set name=None it my data gets added to the default(neo4j$) database but when I try using the database what i created i cannot get my data entered in that database the program runs fine without any error but my data does not get added.

shubham
Node Clone

Thanks @webtic , it worked fine.
is there any time lag in executing the query every time we call it in python?

There is always some overhead of course but in my daily usage I never had the urge to bypass the Python driver in favour of a more native one.