From 33330d63fa70a2a3c1a3c6904f5d1c60f8a31ae6 Mon Sep 17 00:00:00 2001 From: martin bendsoe Date: Mon, 24 Feb 2020 11:53:21 +0100 Subject: [PATCH 01/10] renamed readme and removed aio.rst --- docs/{README.rst => README.md} | 0 docs/source/aio.rst | 2 -- 2 files changed, 2 deletions(-) rename docs/{README.rst => README.md} (100%) delete mode 100644 docs/source/aio.rst diff --git a/docs/README.rst b/docs/README.md similarity index 100% rename from docs/README.rst rename to docs/README.md diff --git a/docs/source/aio.rst b/docs/source/aio.rst deleted file mode 100644 index 290341d75..000000000 --- a/docs/source/aio.rst +++ /dev/null @@ -1,2 +0,0 @@ -.. automodule:: neo4j.aio - :members: From c1f5823c580f5be23560bb59ed1c55fd90e76022 Mon Sep 17 00:00:00 2001 From: martin bendsoe Date: Mon, 24 Feb 2020 11:54:36 +0100 Subject: [PATCH 02/10] changed theme to read the docs --- docs/requirements.txt | 1 + docs/source/conf.py | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index ccbd0b094..118d63a74 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,2 +1,3 @@ neotime sphinx +sphinx-rtd-theme diff --git a/docs/source/conf.py b/docs/source/conf.py index 2b0e53e2e..f4165e09b 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -16,6 +16,7 @@ import sys import os import shlex +import sphinx_rtd_theme # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -38,6 +39,7 @@ 'sphinx.ext.coverage', 'sphinx.ext.ifconfig', 'sphinx.ext.intersphinx', + "sphinx_rtd_theme", ] # Add any paths that contain templates here, relative to this directory. @@ -118,7 +120,8 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -html_theme = 'nature' +# html_theme = 'nature' +html_theme = "sphinx_rtd_theme" # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the @@ -302,6 +305,5 @@ def setup(app): intersphinx_mapping = { 'python': ('https://docs.python.org/3', None), - 'neobolt': ('https://neobolt.readthedocs.io/en/latest/', None), 'neotime': ('https://neotime.readthedocs.io/en/latest/', None), } From 498622c7cd619a625805ada84bedfe3cc0451426 Mon Sep 17 00:00:00 2001 From: martin bendsoe Date: Mon, 24 Feb 2020 11:55:07 +0100 Subject: [PATCH 03/10] changed readme to be markdown --- docs/README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/README.md b/docs/README.md index e9c3a7aa3..b84e3e0dd 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2,9 +2,11 @@ Sphinx Documentation ==================== -From the root of this repository... +``` +pip install -r requirements.txt +``` -.. code:: bash +``` +make -C docs html +``` - pip install -r docs_requirements.txt - make -C docs html From 60cef848c5d76c3670422d8db8414078a617c4ed Mon Sep 17 00:00:00 2001 From: martin bendsoe Date: Mon, 24 Feb 2020 12:29:03 +0100 Subject: [PATCH 04/10] updated the index to include breaking changes --- docs/source/index.rst | 99 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 81 insertions(+), 18 deletions(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index d912359bc..6c3aab376 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -2,8 +2,82 @@ Neo4j Bolt Driver |version| for Python ************************************** -The Official Neo4j Driver for Python supports Neo4j 3.2 and above and requires Python version 2.7 or 3.4+. -Note that support for Python 2.7 will be removed in the 2.0 driver. +The Official Neo4j Driver for Python. + +Neo4j versions supported: + +* Neo4j 4.0 +* Neo4j 3.5 + +Python versions supported: + +* Python 3.8 +* Python 3.7 +* Python 3.6 +* Python 3.5 + + +**Note:** Python 2.7 support has been dropped. + +Use the previous driver (Python Driver 1.7) for older versions of python. + + +Breaking Changes +============ + +Namespace Changes +--------- + +`import neo4j.v1` have changed namespace to be `import neo4j` + + +Secure Connection +--------- + +Neo4j 4.0 is by default configured to use a non secure connection. + +The Driver Configuration argument `encrypted` is by default set to `False`. + +To be able to connect to Neo4j 3.5 set `encrypted=True` to have it configured as the default for that setup. + + +Bookmark Changes +--------- + +Bookmarks is now a Bookmark class instead of a string. + + +Exceptions Changes +--------- + +The exceptions in `import.exceptions` have been updated and there is internal exceptions starting with the naming `Bolt` that should be propagated into the exceptions API. + + +URI Changes +--------- + +`bolt+routing` have been renamed to `neo4j` + + +Class Renaming Changes +--------- + +* `BoltStatementResult` is now `Result` +* `StatementResultSummary` is now `ResultSummary` +* `Statement` is now `Query` + + +Argument Renaming Changes +--------- + +* `statement` is now `query` + + +Dependency Changes +--------- + +The dependency on `neobolt` have been removed. + Quick Example @@ -26,12 +100,6 @@ Quick Example session.read_transaction(print_friends_of, "Alice") -.. note:: - - While imports from ``neo4j.v1`` still work, these will be removed in the 2.0 driver. - It is therefore recommended to change all imports from ``neo4j.v1`` to ``neo4j``. - - Installation ============ @@ -39,12 +107,7 @@ To install the latest stable driver release, use: .. code:: bash - pip install neo4j - -.. note:: - - The driver is currently released under two package names on `PyPI `_: ``neo4j`` and ``neo4j-driver``. - Installing from ``neo4j`` is recommended since ``neo4j-driver`` will be removed in a future release. + python -m pip install neo4j API Documentation @@ -53,18 +116,18 @@ API Documentation .. toctree:: :maxdepth: 1 - aio - Other Information ================= -* `Neo4j Manual`_ +* `Neo4j Documentation`_ +* `The Neo4j Drivers Manual`_ * `Neo4j Quick Reference Card`_ * `Example Project`_ * `Driver Wiki`_ (includes change logs) -.. _`Neo4j Manual`: https://neo4j.com/docs/ +.. _`Neo4j Documentation`: https://neo4j.com/docs/ +.. _`The Neo4j Drivers Manual`: https://neo4j.com/docs/driver-manual/current/ .. _`Neo4j Quick Reference Card`: https://neo4j.com/docs/cypher-refcard/current/ .. _`Example Project`: https://github.com/neo4j-examples/movies-python-bolt .. _`Driver Wiki`: https://github.com/neo4j/neo4j-python-driver/wiki From 6a8cc9b90583dd0d4dde47d5e0e61c5b6947c899 Mon Sep 17 00:00:00 2001 From: martin bendsoe Date: Tue, 25 Feb 2020 12:23:13 +0100 Subject: [PATCH 05/10] updated breaking changes about renaming --- docs/source/index.rst | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index 6c3aab376..bf9b38fce 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -28,7 +28,7 @@ Breaking Changes Namespace Changes --------- -`import neo4j.v1` have changed namespace to be `import neo4j` +:code:`import neo4j.v1` have changed namespace to be :code:`import neo4j` Secure Connection @@ -36,7 +36,7 @@ Secure Connection Neo4j 4.0 is by default configured to use a non secure connection. -The Driver Configuration argument `encrypted` is by default set to `False`. +The Driver Configuration argument :code:`encrypted` is by default set to :code:`False`. To be able to connect to Neo4j 3.5 set `encrypted=True` to have it configured as the default for that setup. @@ -50,7 +50,7 @@ Bookmarks is now a Bookmark class instead of a string. Exceptions Changes --------- -The exceptions in `import.exceptions` have been updated and there is internal exceptions starting with the naming `Bolt` that should be propagated into the exceptions API. +The exceptions in :code:`neo4j.exceptions` have been updated and there is internal exceptions starting with the naming :code:`Bolt` that should be propagated into the exceptions API. URI Changes @@ -62,21 +62,26 @@ URI Changes Class Renaming Changes --------- -* `BoltStatementResult` is now `Result` -* `StatementResultSummary` is now `ResultSummary` -* `Statement` is now `Query` +* :code:`BoltStatementResult` is now :code:`Result` +* :code:`StatementResultSummary` is now :code:`ResultSummary` +* :code:`Statement` is now :code:`Query` Argument Renaming Changes --------- -* `statement` is now `query` +* :code:`statement` is now :code:`query` +* :code:`cypher` is now :code:`query` +* :code:`Session.run(cypher, ...` is now :code:`Session.run(query, ...` +* :code:`Transaction.run(statement, ...` is now :code:`Transaction.run(query, ...` +* :code:`StatementResultSummary.statement` is now :code:`ResultSummary.query` +* :code:`StatementResultSummary.statement_type` is now :code:`ResultSummary.query_type` Dependency Changes --------- -The dependency on `neobolt` have been removed. +The dependency :code:`neobolt` have been removed. From e9077e977800e62757d05cbedee6afa934536428 Mon Sep 17 00:00:00 2001 From: martin bendsoe Date: Tue, 25 Feb 2020 12:51:05 +0100 Subject: [PATCH 06/10] Updated docs --- docs/source/index.rst | 44 +++++++++++++++++++++------------- docs/source/results.rst | 12 ++++++---- docs/source/transactions.rst | 4 ++-- docs/source/usage_patterns.rst | 21 ++++++++++++++++ 4 files changed, 57 insertions(+), 24 deletions(-) create mode 100644 docs/source/usage_patterns.rst diff --git a/docs/source/index.rst b/docs/source/index.rst index bf9b38fce..925c09924 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -1,6 +1,6 @@ -************************************** +###################################### Neo4j Bolt Driver |version| for Python -************************************** +###################################### The Official Neo4j Driver for Python. @@ -22,45 +22,46 @@ Python versions supported: Use the previous driver (Python Driver 1.7) for older versions of python. +**************** Breaking Changes -============ +**************** Namespace Changes ---------- +================= :code:`import neo4j.v1` have changed namespace to be :code:`import neo4j` Secure Connection ---------- +================= Neo4j 4.0 is by default configured to use a non secure connection. The Driver Configuration argument :code:`encrypted` is by default set to :code:`False`. -To be able to connect to Neo4j 3.5 set `encrypted=True` to have it configured as the default for that setup. +To be able to connect to Neo4j 3.5 set :code:`encrypted=True` to have it configured as the default for that setup. Bookmark Changes ---------- +================ Bookmarks is now a Bookmark class instead of a string. Exceptions Changes ---------- +================== The exceptions in :code:`neo4j.exceptions` have been updated and there is internal exceptions starting with the naming :code:`Bolt` that should be propagated into the exceptions API. URI Changes ---------- +=========== `bolt+routing` have been renamed to `neo4j` Class Renaming Changes ---------- +====================== * :code:`BoltStatementResult` is now :code:`Result` * :code:`StatementResultSummary` is now :code:`ResultSummary` @@ -68,7 +69,7 @@ Class Renaming Changes Argument Renaming Changes ---------- +========================= * :code:`statement` is now :code:`query` * :code:`cypher` is now :code:`query` @@ -79,14 +80,14 @@ Argument Renaming Changes Dependency Changes ---------- +================== The dependency :code:`neobolt` have been removed. - +************* Quick Example -============= +************* .. code-block:: python @@ -105,8 +106,9 @@ Quick Example session.read_transaction(print_friends_of, "Alice") +************ Installation -============ +************ To install the latest stable driver release, use: @@ -115,15 +117,23 @@ To install the latest stable driver release, use: python -m pip install neo4j +***************** API Documentation -================= +***************** .. toctree:: :maxdepth: 1 + driver + errors + results + transactions + usage_patterns + +***************** Other Information -================= +***************** * `Neo4j Documentation`_ * `The Neo4j Drivers Manual`_ diff --git a/docs/source/results.rst b/docs/source/results.rst index a3341887c..a8dc23f8b 100644 --- a/docs/source/results.rst +++ b/docs/source/results.rst @@ -2,14 +2,16 @@ Consuming Results ***************** -Every time Cypher is executed, a :class:`neo4j.Result` is returned. +Every time a query is executed, a :class:`.Result` is returned. + This provides a handle to the result of the query, giving access to the records within it as well as the result metadata. Each result consists of header metadata, zero or more :class:`.Record` objects and footer metadata (the summary). Results also contain a buffer that automatically stores unconsumed records when results are consumed out of order. -A :class:`neo4j.Result` is attached to an active connection, through a :class:`.Session`, until all its content has been buffered or consumed. -.. class:: neo4j.Result +A :class:`.Result` is attached to an active connection, through a :class:`.Session`, until all its content has been buffered or consumed. + +.. class:: .Result .. describe:: iter(result) @@ -103,8 +105,8 @@ A :class:`neo4j.Result` is attached to an active connection, through a :class:`. Summary Details --------------- -.. autoclass:: neo4j.ResultSummary +.. autoclass:: .ResultSummary :members: -.. autoclass:: neo4j.SummaryCounters +.. autoclass:: .SummaryCounters :members: diff --git a/docs/source/transactions.rst b/docs/source/transactions.rst index 489cba8b2..a2a823808 100644 --- a/docs/source/transactions.rst +++ b/docs/source/transactions.rst @@ -140,7 +140,7 @@ Note that this mode is simply a default and not a constraint. This means that transaction functions within a session can override the access mode passed to that session on construction. .. note:: - The driver does not parse Cypher statements and cannot determine whether a statement tagged as `read` or `write` is tagged correctly. - Since the access mode is not passed to the server, this can allow a `write` statement to be executed in a `read` call on a single instance. + The driver does not parse Cypher queries and cannot determine whether the access mode should be :code:`ACCESS_READ` or :code:`ACCESS_WRITE`. + Since the access mode is not passed to the server, this can allow a :code:`ACCESS_WRITE` statement to be executed for a :code:`ACCESS_READ` call on a single instance. Clustered environments are not susceptible to this loophole as cluster roles prevent it. This behaviour should not be relied upon as the loophole may be closed in a future release. diff --git a/docs/source/usage_patterns.rst b/docs/source/usage_patterns.rst new file mode 100644 index 000000000..ba87d45e4 --- /dev/null +++ b/docs/source/usage_patterns.rst @@ -0,0 +1,21 @@ +************** +Usage Patterns +************** + +Simple + +.. code-block:: python + + from neo4j import GraphDatabase + + uri = "bolt://localhost:7687" + driver = GraphDatabase.driver(uri, auth=("neo4j", "password")) + + def print_friends_of(tx, name): + for record in tx.run("MATCH (a:Person)-[:KNOWS]->(f) " + "WHERE a.name = {name} " + "RETURN f.name", name=name): + print(record["f.name"]) + + with driver.session() as session: + session.read_transaction(print_friends_of, "Alice") \ No newline at end of file From adb3cc269dd89bee41268eed16718be703a22a9e Mon Sep 17 00:00:00 2001 From: martin bendsoe Date: Tue, 25 Feb 2020 13:55:43 +0100 Subject: [PATCH 07/10] the docs is building ok now. --- docs/source/index.rst | 9 +++++++++ docs/source/results.rst | 2 +- docs/source/transactions.rst | 6 +++--- docs/source/types/graph.rst | 10 +++++----- docs/source/types/spatial.rst | 6 +++--- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index 925c09924..47d276132 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -2,6 +2,10 @@ Neo4j Bolt Driver |version| for Python ###################################### +.. warning:: + This API docs is not production ready! + + The Official Neo4j Driver for Python. Neo4j versions supported: @@ -22,6 +26,7 @@ Python versions supported: Use the previous driver (Python Driver 1.7) for older versions of python. + **************** Breaking Changes **************** @@ -129,6 +134,10 @@ API Documentation results transactions usage_patterns + types/core + types/graph + types/spatial + types/temporal ***************** diff --git a/docs/source/results.rst b/docs/source/results.rst index a8dc23f8b..b93f5201e 100644 --- a/docs/source/results.rst +++ b/docs/source/results.rst @@ -42,7 +42,7 @@ A :class:`.Result` is attached to an active connection, through a :class:`.Sessi .. automethod:: data -.. class:: neo4j.Record +.. class:: .Record A :class:`.Record` is an immutable ordered collection of key-value pairs. It is generally closer to a :py:class:`namedtuple` than to a diff --git a/docs/source/transactions.rst b/docs/source/transactions.rst index a2a823808..c89f72dea 100644 --- a/docs/source/transactions.rst +++ b/docs/source/transactions.rst @@ -25,7 +25,7 @@ For example:: To construct a :class:`.Session` use the :meth:`.Driver.session` method. -.. class:: neo4j.Session +.. class:: .Session .. automethod:: close @@ -75,7 +75,7 @@ Explicit transactions support multiple statements and must be created with an ex This creates a new :class:`.Transaction` object that can be used to run Cypher. It also gives applications the ability to directly control `commit` and `rollback` activity. -.. class:: neo4j.Transaction +.. class:: .Transaction .. automethod:: run @@ -127,7 +127,7 @@ Returning a live result object would prevent the driver from correctly managing To exert more control over how a transaction function is carried out, the :func:`.unit_of_work` decorator can be used. -.. autofunction:: neo4j.unit_of_work +.. autofunction:: neo4j.work.simple.unit_of_work Access modes diff --git a/docs/source/types/graph.rst b/docs/source/types/graph.rst index f2a11a82b..0cd7ddbc8 100644 --- a/docs/source/types/graph.rst +++ b/docs/source/types/graph.rst @@ -18,10 +18,10 @@ Relationship :class:`.Relationship` Path :class:`.Path` ============= ====================== -.. class:: neo4j.types.graph.Graph +.. class:: neo4j.graph.Graph A local, self-contained graph object that acts as a container for :class:`.Node` and :class:`.Relationship` instances. - This is typically obtained via the :meth:`neo4j.Result.graph` method. + This is typically obtained via the :meth:`.Result.graph` method. .. autoattribute:: nodes @@ -30,7 +30,7 @@ Path :class:`.Path` .. automethod:: relationship_type -.. class:: neo4j.types.graph.Node +.. class:: neo4j.graph.Node .. describe:: node == other @@ -76,7 +76,7 @@ Path :class:`.Path` .. automethod:: items -.. class:: neo4j.types.graph.Relationship +.. class:: neo4j.graph.Relationship .. describe:: relationship == other @@ -133,7 +133,7 @@ Path :class:`.Path` .. automethod:: items -.. class:: neo4j.types.graph.Path +.. class:: neo4j.graph.Path .. describe:: path == other diff --git a/docs/source/types/spatial.rst b/docs/source/types/spatial.rst index b1c8313a4..c5f950fce 100644 --- a/docs/source/types/spatial.rst +++ b/docs/source/types/spatial.rst @@ -8,13 +8,13 @@ Cypher Type Python Type Point :class:`.Point` ============= ====================== -.. autoclass:: neo4j.types.spatial.Point +.. autoclass:: neo4j.spatial.Point :members: -.. autoclass:: neo4j.types.spatial.CartesianPoint +.. autoclass:: neo4j.spatial.CartesianPoint :members: :inherited-members: -.. autoclass:: neo4j.types.spatial.WGS84Point +.. autoclass:: neo4j.spatial.WGS84Point :members: :inherited-members: From 2c173f1ad4502b4ff8db7587b5f9080bcf15be19 Mon Sep 17 00:00:00 2001 From: martin bendsoe Date: Tue, 25 Feb 2020 17:39:36 +0100 Subject: [PATCH 08/10] added more patterns --- docs/source/usage_patterns.rst | 272 +++++++++++++++++++++++++++++++-- 1 file changed, 262 insertions(+), 10 deletions(-) diff --git a/docs/source/usage_patterns.rst b/docs/source/usage_patterns.rst index ba87d45e4..461206380 100644 --- a/docs/source/usage_patterns.rst +++ b/docs/source/usage_patterns.rst @@ -1,21 +1,273 @@ -************** +############## Usage Patterns -************** +############## -Simple +.. warning:: + This section is experimental! Breaking changes will occur! + + +****************** +Simple Application +****************** .. code-block:: python from neo4j import GraphDatabase - uri = "bolt://localhost:7687" - driver = GraphDatabase.driver(uri, auth=("neo4j", "password")) def print_friends_of(tx, name): - for record in tx.run("MATCH (a:Person)-[:KNOWS]->(f) " - "WHERE a.name = {name} " - "RETURN f.name", name=name): + query = "MATCH (a:Person)-[:KNOWS]->(f) WHERE a.name = {name} RETURN f.name" + + result = tx.run(query, name=name) + + for record in result: print(record["f.name"]) - with driver.session() as session: - session.read_transaction(print_friends_of, "Alice") \ No newline at end of file + + if __name__ == "main": + + uri = "bolt://localhost:7687" + driver = GraphDatabase.driver(uri, auth=("neo4j", "password")) + + with driver.session() as session: + session.read_transaction(print_friends_of, "Alice") + + driver.close() + + +********************************** +Driver Initialization Work Pattern +********************************** + +.. code-block:: python + + from neo4j import GraphDatabase + from neo4j.exceptions import ServiceUnavailable + + uri = "bolt://localhost:7687" + + driver_config = { + "encrypted": False, + "trust": None, + "user_agent": "example", + "max_connection_lifetime": 1000, + "max_connection_pool_size": 100, + "connection_acquisition_timeout": 10, + "connection_timeout": 1, + "keep_alive": False, + "max_retry_time": 10, + "resolver": None, + } + + try: + driver = GraphDatabase.driver(uri, auth=("neo4j", "password"), **driver_config) + driver.close() + except ServiceUnavailable as e: + print(e) + + +Driver Initialization With Block Work Pattern +============================================= + +.. Investigate the example 6 pattern for error handling + https://www.python.org/dev/peps/pep-0343/#examples + + +.. code-block:: python + + from neo4j import GraphDatabase + + with GraphDatabase.driver(uri, auth=("neo4j", "password"), **driver_config) as driver: + try: + session = driver.session() + session.close() + except ServiceUnavailable as e: + print(e) + +*********************************** +Session Initialization Work Pattern +*********************************** + +.. code-block:: python + + from neo4j import ( + ACCESS_READ, + ACCESS_WRITE, + ) + + session_config = { + "fetch_size": 100, + "database": "default", + "bookmarks": ["bookmark-1",], + "access_mode": ACCESS_WRITE, + "acquire_timeout": 60.0, + "max_retry_time": 30.0, + "initial_retry_delay": 1.0, + "retry_delay_multiplier": 2.0, + "retry_delay_jitter_factor": 0.2, + } + + try: + session = driver.session(access_mode=None, **session_config) + session.close() + except ServiceUnavailable as e: + print(e) + + +Session Initialization With Block Work Pattern +============================================== + +.. Investigate the example 6 pattern for error handling + https://www.python.org/dev/peps/pep-0343/#examples + + +.. code-block:: python + + from neo4j.exceptions import ServiceUnavailable + + query = "RETURN 1 AS x" + + with driver.session(access_mode=None, **session_config) as session: + try: + result = session.run(query) + for record in result: + print(record["x"]) + except ServiceUnavailable as e: + print(e) + + +******************************* +Session Autocommit Work Pattern +******************************* + +.. code-block:: python + + statement = "RETURN $tag AS $name" + + kwparameters = {"name": "test", "tag": 123} + + session.run(query) + + session.run(query, parameters=None, **kwparameters) + + session.run(query, parameters={"name": "test", "tag": 123}) + + session.run(query, parameters={"name": "test", "tag": 123}, **kwparameters) + + session.run(query, name="test", "tag"=123) + + +**************************************** +Session Managed Transaction Work Pattern +**************************************** + +.. code-block:: python + + def test_work(tx, *args, **kwargs): + query = "RETURN $tag AS $name" + + kwparameters = {"name": "test", "tag": 123} + + tx.run(query) + + tx.run(query, parameters=None, **kwparameters) + + tx.run(query, parameters={"name": "test", "tag": 123}) + + tx.run(query, parameters={"name": "test", "tag": 123}, **kwparameters) + + tx.run(query, name="test", "tag"=123) + + + session.read_transaction(test_work) + + session.read_transaction(test_work, *args, **kwargs) + + session.read_transaction(test_work, **kwargs) + + + session.write_transaction(test_work) + + session.write_transaction(test_work, *args, **kwargs) + + session.write_transaction(test_work, **kwargs) + + +unit_of_work +============ + +.. code-block:: python + + from neo4j import unit_of_work + + + @unit_of_work(timeout=10) + def test_work(tx, *args, **kwargs): + query = "RETURN $tag AS $name" + + result = tx.run(query) + # The result needs to be consumed + + session.read_transaction(test_work) + + +.. code-block:: python + + from neo4j import unit_of_work + + + @unit_of_work(metadata={"hello": 123}) + def test_work(tx, *args, **kwargs): + query = "RETURN $tag AS $name" + + result = tx.run(query) + # The result needs to be consumed + + session.read_transaction(test_work) + + +.. code-block:: python + + from neo4j import unit_of_work + + + @unit_of_work(timeout=10, metadata={"hello": 123}) + def test_work(tx, *args, **kwargs): + query = "RETURN $tag AS $name" + + result = tx.run(query) + # The result needs to be consumed + + session.read_transaction(test_work) + + +The Query Object Work Pattern +============================= + +.. code-block:: python + + from neo4j import Query + + + def test_work(tx, *args, **kwargs): + query = Query("RETURN 1 AS x, timeout=10, metadata={"hello": 123}) + + result = tx.run(query) + # The result needs to be consumed + + session.read_transaction(test_work) + + + + +******************************* +Transaction Object Work Pattern +******************************* + +.. code-block:: python + + query = Query("RETURN 1 AS x, timeout=10, metadata={"hello": 123}) + + tx = session.begin_transaction(bookmark=None, metadata=None, timeout=None) + tx.run(query) + tx.commit() From 765eeaa191a60f20db6a3522b6802ad2b0567edb Mon Sep 17 00:00:00 2001 From: martin bendsoe Date: Wed, 26 Feb 2020 14:07:29 +0100 Subject: [PATCH 09/10] improved index Renamed the headline to be Neo4j Python Driver Added the Bolt Protocol Version information for the supported Neo4j versions. --- docs/source/index.rst | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index 47d276132..7649255c9 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -1,6 +1,6 @@ -###################################### -Neo4j Bolt Driver |version| for Python -###################################### +############################# +Neo4j Python Driver |version| +############################# .. warning:: This API docs is not production ready! @@ -10,8 +10,8 @@ The Official Neo4j Driver for Python. Neo4j versions supported: -* Neo4j 4.0 -* Neo4j 3.5 +* Neo4j 4.0 - Using the Bolt Protocol Version 4.0 +* Neo4j 3.5 - Using the Bolt Protocol Version 3 Python versions supported: @@ -23,14 +23,23 @@ Python versions supported: **Note:** Python 2.7 support has been dropped. -Use the previous driver (Python Driver 1.7) for older versions of python. +.. note:: + The driver may still work with older versions of python. + The previous driver `Python Driver 1.7`_ supports older versions of python, + the Neo4j 4.0 will work in fallback mode (using Bolt Protocol Version 3) with that driver. **************** Breaking Changes **************** +Version Scheme Changes +====================== + +The version number have jumped from :code:`1.7` to :code:`Python Driver 4.0` to align with the Neo4j Database version scheme. + + Namespace Changes ================= @@ -150,6 +159,7 @@ Other Information * `Example Project`_ * `Driver Wiki`_ (includes change logs) +.. _`Python Driver 1.7`: https://neo4j.com/docs/api/python-driver/1.7/ .. _`Neo4j Documentation`: https://neo4j.com/docs/ .. _`The Neo4j Drivers Manual`: https://neo4j.com/docs/driver-manual/current/ .. _`Neo4j Quick Reference Card`: https://neo4j.com/docs/cypher-refcard/current/ From 5dd2de92d285fee6a22a22dd9884a4443ce7f07d Mon Sep 17 00:00:00 2001 From: martin bendsoe Date: Wed, 26 Feb 2020 14:54:24 +0100 Subject: [PATCH 10/10] added link to migration guide on index page --- docs/source/index.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/source/index.rst b/docs/source/index.rst index 7649255c9..b680148f8 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -158,6 +158,7 @@ Other Information * `Neo4j Quick Reference Card`_ * `Example Project`_ * `Driver Wiki`_ (includes change logs) +* `Migration Guide - Upgrade Neo4j drivers`_ .. _`Python Driver 1.7`: https://neo4j.com/docs/api/python-driver/1.7/ .. _`Neo4j Documentation`: https://neo4j.com/docs/ @@ -165,3 +166,4 @@ Other Information .. _`Neo4j Quick Reference Card`: https://neo4j.com/docs/cypher-refcard/current/ .. _`Example Project`: https://github.com/neo4j-examples/movies-python-bolt .. _`Driver Wiki`: https://github.com/neo4j/neo4j-python-driver/wiki +.. _`Migration Guide - Upgrade Neo4j drivers`: https://neo4j.com/docs/migration-guide/4.0/upgrade-driver/