Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
03-09-2021 04:31 PM
A simple approach is to just start a new session when this class is instantiated, then save it as an object attribute, and just re-use as needed... As simple as it gets!
~
And yet, the Neo4j Python Driver 4.2 API Documentation says:
a session should generally be short-lived... In general, sessions will be created and destroyed within a with context
~
On a similar note, The session API - Neo4j Driver Manual says
In languages that support them, simple sessions are usually scoped within a context block; this ensures that they are properly closed and that any underlying connections are released and not leaked.
~
However, it'd seem that the simple approach of doing everything within the same 1 session, also prevents any danger of leaking sessions!
~
On this forum, I found Best way to use Neo4J driver sessions , but it doesn't really answer my question. It only provided a case report:
The most common way I've seen is to have one session for reads and another for writes
~
I'd love to hear about pros and cons...
I'd love to hear about best practices...
~
I presume the best approach may depend on single vs. multiple nodes... and on the amount of concurrent traffic ?
Thanks!
All the sessions of the conference are now available online