@@ -566,9 +566,44 @@ Name of the database to query.
566
566
The default database can be set on the Neo4j instance settings.
567
567
568
568
.. Note ::
569
- It is recommended to always specify the database explicitly when possible.
570
- This allows the driver to work more efficiently, as it will not have to
571
- resolve the home database first.
569
+
570
+ This option has no explicit value by default, but it is recommended to set
571
+ one if the target database is known in advance. This has the benefit of
572
+ ensuring a consistent target database name throughout the session in a
573
+ straightforward way and potentially simplifies driver logic as well as
574
+ reduces network communication resulting in better performance.
575
+
576
+ Usage of Cypher clauses like `USE ` is not a replacement for this option.
577
+ The driver does not parse any Cypher.
578
+
579
+ When no explicit name is set, the driver behavior depends on the connection
580
+ URI scheme supplied to the driver on instantiation and Bolt protocol
581
+ version.
582
+
583
+ Specifically, the following applies:
584
+
585
+ - **bolt schemes ** - queries are dispatched to the server for execution
586
+ without explicit database name supplied, meaning that the target database
587
+ name for query execution is determined by the server. It is important to
588
+ note that the target database may change (even within the same session),
589
+ for instance if the user's home database is changed on the server.
590
+
591
+ - **neo4j schemes ** - providing that Bolt protocol version 4.4, which was
592
+ introduced with Neo4j server 4.4, or above is available, the driver
593
+ fetches the user's home database name from the server on first query
594
+ execution within the session and uses the fetched database name
595
+ explicitly for all queries executed within the session. This ensures that
596
+ the database name remains consistent within the given session. For
597
+ instance, if the user's home database name is 'movies' and the server
598
+ supplies it to the driver upon database name fetching for the session,
599
+ all queries within that session are executed with the explicit database
600
+ name 'movies' supplied. Any change to the user’s home database is
601
+ reflected only in sessions created after such change takes effect. This
602
+ behavior requires additional network communication. In clustered
603
+ environments, it is strongly recommended to avoid a single point of
604
+ failure. For instance, by ensuring that the connection URI resolves to
605
+ multiple endpoints. For older Bolt protocol versions the behavior is the
606
+ same as described for the **bolt schemes ** above.
572
607
573
608
574
609
.. code-block :: python
0 commit comments