22Neo4j Bolt Driver for Python
33****************************
44
5- The Official Neo4j Driver for Python supports Neo4j 3.0 and above and Python versions 2.7, 3.4 and 3.5 .
5+ The Official Neo4j Driver for Python supports Neo4j 3.0 and above and Python versions 2.7, 3.4, 3.5 and 3.6 .
66
77
88Quick Example
@@ -14,14 +14,21 @@ Quick Example
1414
1515 driver = GraphDatabase.driver(" bolt://localhost:7687" , auth = (" neo4j" , " password" ))
1616
17+ def add_friends (tx , name , friend_name ):
18+ tx.run(" MERGE (a:Person {name: $name} ) "
19+ " MERGE (a)-[:KNOWS]->(friend:Person {name: $friend_name} })" ,
20+ name = name, friend_name = friend_name)
21+
1722 def print_friends (tx , name ):
18- for record in tx.run(" MATCH (a:Person)-[:KNOWS]->(friend) "
19- " WHERE a.name = {name} "
20- " RETURN friend.name" , name = name):
23+ for record in tx.run(" MATCH (a:Person)-[:KNOWS]->(friend) WHERE a.name = $name} "
24+ " RETURN friend.name ORDER BY friend.name" , name = name):
2125 print (record[" friend.name" ])
2226
2327 with driver.session() as session:
24- session.read_transaction(print_friends, " Alice" )
28+ session.write_transaction(add_friends, " Arthur" , " Guinevere" )
29+ session.write_transaction(add_friends, " Arthur" , " Lancelot" )
30+ session.write_transaction(add_friends, " Arthur" , " Merlin" )
31+ session.read_transaction(print_friends, " Arthur" )
2532
2633
2734 Installation
@@ -33,7 +40,7 @@ To install the latest stable version, use:
3340
3441 pip install neo4j-driver
3542
36- For the most up-to-date version (possibly unstable), use:
43+ For the most up-to-date version (generally unstable), use:
3744
3845.. code :: bash
3946
0 commit comments