|
1 | | -============================ |
| 1 | +**************************** |
2 | 2 | Neo4j Bolt Driver for Python |
3 | | -============================ |
| 3 | +**************************** |
4 | 4 |
|
5 | | -.. toctree:: |
6 | | - :maxdepth: 2 |
7 | | - |
8 | | - |
9 | | -Session API |
10 | | -=========== |
11 | | - |
12 | | -.. autoclass:: neo4j.v1.GraphDatabase |
13 | | - :members: |
14 | | - |
15 | | -.. autoclass:: neo4j.v1.Driver |
16 | | - :members: |
17 | | - |
18 | | -.. autoclass:: neo4j.v1.Session |
19 | | - :members: |
20 | | - |
21 | | -.. autoclass:: neo4j.v1.Transaction |
22 | | - :members: |
23 | | - |
24 | | -.. autoclass:: neo4j.v1.Record |
25 | | - :members: |
26 | | - |
27 | | -.. autoclass:: neo4j.v1.StatementResult |
28 | | - :members: |
| 5 | +The Official Neo4j Driver for Python supports Neo4j 3.0 and above and Python versions 2.7, 3.4 and 3.5. |
29 | 6 |
|
30 | 7 |
|
31 | | -Encryption Settings |
32 | | -------------------- |
33 | | -.. py:attribute:: neo4j.v1.ENCRYPTION_OFF |
34 | | -.. py:attribute:: neo4j.v1.ENCRYPTION_ON |
35 | | -.. py:attribute:: neo4j.v1.ENCRYPTION_NON_LOCAL |
36 | | -.. py:attribute:: neo4j.v1.ENCRYPTION_DEFAULT |
| 8 | +Quick Example |
| 9 | +============= |
37 | 10 |
|
| 11 | +.. code-block:: python |
38 | 12 |
|
39 | | -Trust Settings |
40 | | --------------- |
41 | | -.. py:attribute:: neo4j.v1.TRUST_ON_FIRST_USE |
42 | | -.. py:attribute:: neo4j.v1.TRUST_SIGNED_CERTIFICATES |
43 | | -.. py:attribute:: neo4j.v1.TRUST_DEFAULT |
44 | | -
|
45 | | -
|
46 | | -Query Summary Details |
47 | | ---------------------- |
48 | | - |
49 | | -.. autoclass:: neo4j.v1.summary.ResultSummary |
50 | | - :members: |
51 | | - |
52 | | -.. autoclass:: neo4j.v1.summary.SummaryCounters |
53 | | - :members: |
| 13 | + from neo4j.v1 import GraphDatabase, basic_auth |
54 | 14 |
|
| 15 | + uri = "bolt://localhost:7687" |
| 16 | + auth_token = basic_auth("neo4j", "password") |
| 17 | + driver = GraphDatabase.driver(uri, auth=auth_token) |
55 | 18 |
|
56 | | -Exceptions |
57 | | -========== |
| 19 | + def print_friends_of(name): |
| 20 | + with driver.session() as session: |
| 21 | + with session.begin_transaction() as tx: |
| 22 | + for record in tx.run("MATCH (a:Person)-[:KNOWS]->(f) " |
| 23 | + "WHERE a.name = {name} " |
| 24 | + "RETURN f.name", name=name): |
| 25 | + print(record["f.name"]) |
58 | 26 |
|
59 | | -.. autoclass:: neo4j.v1.ProtocolError |
60 | | - :members: |
| 27 | + print_friends_of("Alice") |
61 | 28 |
|
62 | | -.. autoclass:: neo4j.v1.CypherError |
63 | | - :members: |
64 | 29 |
|
65 | | -.. autoclass:: neo4j.v1.ResultError |
66 | | - :members: |
| 30 | +Installation |
| 31 | +============ |
67 | 32 |
|
| 33 | +To install the latest stable version, use: |
68 | 34 |
|
69 | | -Example |
70 | | -======= |
| 35 | +.. code:: bash |
71 | 36 |
|
72 | | -.. code-block:: python |
| 37 | + pip install neo4j-driver |
73 | 38 |
|
74 | | - from neo4j.v1 import GraphDatabase, basic_auth |
| 39 | +For the most up-to-date version (possibly unstable), use: |
75 | 40 |
|
76 | | - driver = GraphDatabase.driver("bolt://localhost:7687", auth=basic_auth("neo4j", "password")) |
| 41 | +.. code:: bash |
77 | 42 |
|
78 | | - with driver.session() as session: |
| 43 | + pip install git+https://github.com/neo4j/neo4j-python-driver.git#egg=neo4j-driver |
79 | 44 |
|
80 | | - with session.begin_transaction() as tx: |
81 | | - session.run("MERGE (a:Person {name:'Alice'})") |
82 | 45 |
|
83 | | - friends = ["Bob", "Carol", "Dave", "Eve", "Frank"] |
84 | | - with session.begin_transaction() as tx: |
85 | | - for friend in friends: |
86 | | - tx.run("MATCH (a:Person {name:'Alice'}) " |
87 | | - "MERGE (a)-[:KNOWS]->(x:Person {name:{n}})", {"n": friend}) |
| 46 | +API Documentation |
| 47 | +================= |
88 | 48 |
|
89 | | - for record in session.run("MATCH (a:Person {name:'Alice'})-[:KNOWS]->(friend) RETURN friend"): |
90 | | - print('Alice says, "hello, %s"' % record["friend"]["name"]) |
| 49 | +.. toctree:: |
| 50 | + :maxdepth: 1 |
91 | 51 |
|
92 | | - driver.close() |
| 52 | + driver |
| 53 | + session |
| 54 | + types |
93 | 55 |
|
94 | 56 |
|
95 | | -Indices and tables |
96 | | -================== |
| 57 | +Other Information |
| 58 | +================= |
97 | 59 |
|
98 | | -* :ref:`genindex` |
99 | | -* :ref:`modindex` |
100 | | -* :ref:`search` |
| 60 | +* `Neo4j Manual`_ |
| 61 | +* `Neo4j Quick Reference Card`_ |
| 62 | +* `Example Project`_ |
| 63 | +* `Driver Wiki`_ (includes change logs) |
101 | 64 |
|
| 65 | +.. _`Neo4j Manual`: https://neo4j.com/docs/ |
| 66 | +.. _`Neo4j Quick Reference Card`: https://neo4j.com/docs/cypher-refcard/current/ |
| 67 | +.. _`Example Project`: https://github.com/neo4j-examples/movies-python-bolt |
| 68 | +.. _`Driver Wiki`: https://github.com/neo4j/neo4j-python-driver/wiki |
0 commit comments