@@ -11,7 +11,7 @@ GraphDatabase
11
11
Driver Construction
12
12
===================
13
13
14
- The :class: `neo4j.Driver ` construction is via a `classmethod ` on the :class: `neo4j.GraphDatabase ` class.
14
+ The :class: `neo4j.Driver ` construction is done via a `classmethod ` on the :class: `neo4j.GraphDatabase ` class.
15
15
16
16
.. autoclass :: neo4j.GraphDatabase
17
17
:members: driver
@@ -24,18 +24,19 @@ Example, driver creation:
24
24
from neo4j import GraphDatabase
25
25
26
26
uri = " neo4j://example.com:7687"
27
- driver = GraphDatabase.driver(uri, auth = (" neo4j" , " password" ), max_connection_lifetime = 1000 )
27
+ driver = GraphDatabase.driver(uri, auth = (" neo4j" , " password" ))
28
28
29
29
driver.close() # close the driver object
30
30
31
31
32
- For basic auth, this can be a simple tuple, for example:
32
+ For basic authentication, ` auth ` can be a simple tuple, for example:
33
33
34
34
.. code-block :: python
35
35
36
36
auth = (" neo4j" , " password" )
37
37
38
- This will implicitly create a :class: `neo4j.Auth ` with a ``scheme="basic" ``
38
+ This will implicitly create a :class: `neo4j.Auth ` with a ``scheme="basic" ``.
39
+ Other authentication methods are described under :ref: `auth-ref `.
39
40
40
41
41
42
Example, with block context:
@@ -345,11 +346,9 @@ BoltDriver
345
346
URI schemes:
346
347
``bolt ``, ``bolt+ssc ``, ``bolt+s ``
347
348
348
- Driver subclass:
349
- :class: `neo4j.BoltDriver `
349
+ Will result in:
350
350
351
- ..
352
- .. autoclass:: neo4j.BoltDriver
351
+ .. autoclass :: neo4j.BoltDriver
353
352
354
353
355
354
.. _neo4j-driver-ref :
@@ -360,11 +359,9 @@ Neo4jDriver
360
359
URI schemes:
361
360
``neo4j ``, ``neo4j+ssc ``, ``neo4j+s ``
362
361
363
- Driver subclass:
364
- :class: `neo4j.Neo4jDriver `
362
+ Will result in:
365
363
366
- ..
367
- .. autoclass:: neo4j.Neo4jDriver
364
+ .. autoclass :: neo4j.Neo4jDriver
368
365
369
366
370
367
***********************
@@ -604,7 +601,8 @@ Example:
604
601
605
602
def create_person (driver , name ):
606
603
with driver.session(default_access_mode = neo4j.WRITE_ACCESS ) as session:
607
- result = session.run(" CREATE (a:Person { name: $name }) RETURN id(a) AS node_id" , name = name)
604
+ query = " CREATE (a:Person { name: $name }) RETURN id(a) AS node_id"
605
+ result = session.run(query, name = name)
608
606
record = result.single()
609
607
return record[" node_id" ]
610
608
@@ -665,13 +663,15 @@ Example:
665
663
tx.close()
666
664
667
665
def create_person_node (tx ):
666
+ query = " CREATE (a:Person { name: $name }) RETURN id(a) AS node_id"
668
667
name = " default_name"
669
- result = tx.run(" CREATE (a:Person { name: $name }) RETURN id(a) AS node_id " , name = name)
668
+ result = tx.run(query , name = name)
670
669
record = result.single()
671
670
return record[" node_id" ]
672
671
673
672
def set_person_name (tx , node_id , name ):
674
- result = tx.run(" MATCH (a:Person) WHERE id(a) = $id SET a.name = $name" , id = node_id, name = name)
673
+ query = " MATCH (a:Person) WHERE id(a) = $id SET a.name = $name"
674
+ result = tx.run(query, id = node_id, name = name)
675
675
info = result.consume()
676
676
# use the info for logging etc.
677
677
@@ -698,7 +698,8 @@ Example:
698
698
node_id = session.write_transaction(create_person_tx, name)
699
699
700
700
def create_person_tx (tx , name ):
701
- result = tx.run(" CREATE (a:Person { name: $name }) RETURN id(a) AS node_id" , name = name)
701
+ query = " CREATE (a:Person { name: $name }) RETURN id(a) AS node_id"
702
+ result = tx.run(query, name = name)
702
703
record = result.single()
703
704
return record[" node_id" ]
704
705
@@ -708,12 +709,6 @@ To exert more control over how a transaction function is carried out, the :func:
708
709
709
710
710
711
711
-
712
-
713
-
714
-
715
-
716
-
717
712
******
718
713
Result
719
714
******
0 commit comments