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.

How to close py2neo.Graph() connection to Neo4j database

Hi All,
I am connecting to Neo4j Database in Python script like below:

from py2neo import Graph
graph = Graph(uri,auth=(user,password))
graph.run() or graph.evaluate() running for CREATE/MERGE statements.
There is no close() method with Graph().
GraphDatabase.driver is not feasible because needs to change a lot inside the script.
Please let me know how to close the connection from the connection pool at the end of the Python script for graph = Graph() Neo4j connection. Thanks.

1 REPLY 1

Hi @naikum, I have been using py2neo around 10 months or so. As far as I know there is no close() method.

my 2 cents

In the Graph context you can use a timeout, if you know the time length of your transactions.

-> auto ( readonly=False , after=None , metadata=None , timeout=None
-> begin ( autocommit=False , readonly=False , after=None , metadata=None , timeout=None )

I am now trying to migrate from py2neo to Neo4j Python Driver, for few reasons -

  1. Our production is a cluster. py2neo doesn't support routing with Neo4j Causal cluster.
  2. Close method() -> We encountered connection pool full exceptions (sometimes) with py2neo. Neo4j Python driver has a close method.

Hope this helps.....