I am working on loading AGE into NetworkX.
What’s the rationale behind cursor
getting closed automatically when execCypher()
commit argument is True and not being to access the data in it.
Secondly, how do I get the data stored in cursor
to access it after execCypher()
is executed?
2
Answers
The rationale is to make sure your executed query has the returned data within the cursor. Remember that the Postgres instance needs to make sure of avoiding any race conditions, this is especially true when your client application will be attempting to run queries onto a pool created for the Postgres server connection.
To get back the return values of your query you can use one of the fetch commands:
cursor.fetchall()
As the AGE driver for python utilises Psycopg2 for all its transactions, you can refer to the Psycopg2 documentation for further clarification about the cursor class
the cursor gets closed automatically to make sure that the transaction is successful -to know more about transactions in this link –
and to prevent some other resource-related issues like deadlock.
with reference to @RU-D answer here to know more about cursor class and how to fetch the stored data