Skip to content

Commit 2c99079

Browse files
authored
Merge pull request #112 from neo4j/1.1-apidocs
Updated API docs
2 parents 696f4ef + fdae3e4 commit 2c99079

File tree

12 files changed

+233
-144
lines changed

12 files changed

+233
-144
lines changed

README.rst

Lines changed: 33 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,57 @@
1-
============================
1+
****************************
22
Neo4j Bolt Driver for Python
3-
============================
3+
****************************
44

5-
6-
Installation
7-
============
8-
9-
To install the latest stable version, use:
10-
11-
.. code:: bash
12-
13-
pip install neo4j-driver
14-
15-
For the most up-to-date version (possibly unstable), use:
16-
17-
.. code:: bash
18-
19-
pip install git+https://github.com/neo4j/neo4j-python-driver.git#egg=neo4j-driver
5+
The Official Neo4j Driver for Python supports Neo4j 3.0 and above and Python versions 2.7, 3.4 and 3.5.
206

217

22-
Example Usage
8+
Quick Example
239
=============
2410

25-
.. code:: python
11+
.. code-block:: python
2612
2713
from neo4j.v1 import GraphDatabase, basic_auth
2814
29-
driver = GraphDatabase.driver("bolt://localhost:7687", auth=basic_auth("neo4j", "password"))
15+
uri = "bolt://localhost:7687"
16+
auth_token = basic_auth("neo4j", "password")
17+
driver = GraphDatabase.driver(uri, auth=auth_token)
3018
31-
with driver.session() as session:
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"])
3226
33-
with session.begin_transaction() as write_tx:
34-
write_tx.run("CREATE (a:Person {name:{name},age:{age}})", name="Alice", age=33)
35-
write_tx.run("CREATE (a:Person {name:{name},age:{age}})", name="Bob", age=44)
27+
print_friends_of("Alice")
3628
37-
with session.begin_transaction() as read_tx:
38-
result = read_tx.run("MATCH (a:Person) RETURN a.name AS name, a.age AS age")
39-
for record in result:
40-
print("%s is %d years old" % (record["name"], record["age"]))
4129
42-
driver.close()
43-
44-
45-
Command Line
30+
Installation
4631
============
4732

33+
To install the latest stable version, use:
34+
4835
.. code:: bash
4936
50-
python -m neo4j "CREATE (a:Person {name:'Alice'}) RETURN a, labels(a), a.name"
37+
pip install neo4j-driver
38+
39+
For the most up-to-date version (possibly unstable), use:
5140

41+
.. code:: bash
5242
53-
Documentation
54-
=============
43+
pip install git+https://github.com/neo4j/neo4j-python-driver.git#egg=neo4j-driver
5544
56-
For more information such as manual, driver API documentations, changelogs, please find them in the wiki of this repo.
5745
58-
* `Driver Wiki`_
46+
Other Information
47+
=================
48+
5949
* `Neo4j Manual`_
60-
* `Neo4j Refcard`_
61-
* `Sample Project Using Driver`_
50+
* `Neo4j Quick Reference Card`_
51+
* `Example Project`_
52+
* `Driver Wiki`_ (includes change logs)
6253

63-
.. _`Sample Project Using Driver`: https://github.com/neo4j-examples/movies-python-bolt
64-
.. _`Driver Wiki`: https://github.com/neo4j/neo4j-python-driver/wiki
6554
.. _`Neo4j Manual`: https://neo4j.com/docs/
66-
.. _`Neo4j Refcard`: https://neo4j.com/docs/cypher-refcard/current/
55+
.. _`Neo4j Quick Reference Card`: https://neo4j.com/docs/cypher-refcard/current/
56+
.. _`Example Project`: https://github.com/neo4j-examples/movies-python-bolt
57+
.. _`Driver Wiki`: https://github.com/neo4j/neo4j-python-driver/wiki

docs/source/driver.rst

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
**************
2+
Driver Objects
3+
**************
4+
5+
A `Driver` object holds the detail of a Neo4j database including server URIs, credentials and other configuration.
6+
It also manages a pool of connections which are used to power :class:`.Session` instances.
7+
8+
The scheme of the URI passed to the `Driver` constructor determines the type of `Driver` object constructed.
9+
Two types are currently available: the :class:`.DirectDriver` and the :class:`.RoutingDriver`.
10+
These are described in more detail below.
11+
12+
13+
.. autoclass:: neo4j.v1.GraphDatabase
14+
:members:
15+
16+
.. autoclass:: neo4j.v1.DirectDriver
17+
:members:
18+
:inherited-members:
19+
20+
.. autoclass:: neo4j.v1.RoutingDriver
21+
:members:
22+
:inherited-members:
23+
24+
.. autoclass:: neo4j.v1.AuthToken
25+
:members:
26+
27+
.. autofunction:: neo4j.v1.basic_auth
28+
29+
.. autofunction:: neo4j.v1.custom_auth
30+
31+
32+
Encryption Settings
33+
-------------------
34+
.. py:attribute:: neo4j.v1.ENCRYPTION_OFF
35+
.. py:attribute:: neo4j.v1.ENCRYPTION_ON
36+
.. py:attribute:: neo4j.v1.ENCRYPTION_DEFAULT
37+
38+
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_ALL_CERTIFICATES
44+
.. py:attribute:: neo4j.v1.TRUST_CUSTOM_CA_SIGNED_CERTIFICATES
45+
.. py:attribute:: neo4j.v1.TRUST_SYSTEM_CA_SIGNED_CERTIFICATES
46+
.. py:attribute:: neo4j.v1.TRUST_DEFAULT

docs/source/index.rst

Lines changed: 43 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,68 @@
1-
============================
1+
****************************
22
Neo4j Bolt Driver for Python
3-
============================
3+
****************************
44

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.
296

307

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+
=============
3710

11+
.. code-block:: python
3812
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
5414
15+
uri = "bolt://localhost:7687"
16+
auth_token = basic_auth("neo4j", "password")
17+
driver = GraphDatabase.driver(uri, auth=auth_token)
5518
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"])
5826
59-
.. autoclass:: neo4j.v1.ProtocolError
60-
:members:
27+
print_friends_of("Alice")
6128
62-
.. autoclass:: neo4j.v1.CypherError
63-
:members:
6429
65-
.. autoclass:: neo4j.v1.ResultError
66-
:members:
30+
Installation
31+
============
6732

33+
To install the latest stable version, use:
6834

69-
Example
70-
=======
35+
.. code:: bash
7136
72-
.. code-block:: python
37+
pip install neo4j-driver
7338
74-
from neo4j.v1 import GraphDatabase, basic_auth
39+
For the most up-to-date version (possibly unstable), use:
7540

76-
driver = GraphDatabase.driver("bolt://localhost:7687", auth=basic_auth("neo4j", "password"))
41+
.. code:: bash
7742
78-
with driver.session() as session:
43+
pip install git+https://github.com/neo4j/neo4j-python-driver.git#egg=neo4j-driver
7944
80-
with session.begin_transaction() as tx:
81-
session.run("MERGE (a:Person {name:'Alice'})")
8245
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+
=================
8848

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
9151

92-
driver.close()
52+
driver
53+
session
54+
types
9355

9456

95-
Indices and tables
96-
==================
57+
Other Information
58+
=================
9759

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)
10164

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

docs/source/session.rst

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
***************
2+
Cypher Sessions
3+
***************
4+
5+
6+
.. autoclass:: neo4j.v1.Session
7+
:members:
8+
9+
.. autoclass:: neo4j.v1.Transaction
10+
:members:
11+
12+
.. autoclass:: neo4j.v1.StatementResult
13+
:members:
14+
15+
.. autoclass:: neo4j.v1.Record
16+
:members:
17+
18+
19+
Summary Details
20+
---------------
21+
22+
.. autoclass:: neo4j.v1.summary.ResultSummary
23+
:members:
24+
25+
.. autoclass:: neo4j.v1.summary.SummaryCounters
26+
:members:
27+
28+
29+
Exceptions
30+
----------
31+
32+
.. autoclass:: neo4j.v1.ProtocolError
33+
:members:
34+
35+
.. autoclass:: neo4j.v1.Unauthorized
36+
:members:
37+
38+
.. autoclass:: neo4j.v1.CypherError
39+
:members:
40+
41+
.. autoclass:: neo4j.v1.TransactionError
42+
:members:
43+
44+
.. autoclass:: neo4j.v1.ResultError
45+
:members:
46+
47+
.. autoclass:: neo4j.v1.ServiceUnavailable
48+
:members:
49+
50+
.. autoclass:: neo4j.v1.SessionExpired
51+
:members:

docs/source/types.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
***********
2+
Type System
3+
***********
4+
5+
6+
.. autoclass:: neo4j.v1.Node
7+
:members:
8+
:inherited-members:
9+
10+
.. autoclass:: neo4j.v1.Relationship
11+
:members:
12+
:inherited-members:
13+
14+
.. autoclass:: neo4j.v1.Path
15+
:members:
16+
:inherited-members:

neo4j/v1/bolt.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
the `session` module provides the main user-facing abstractions.
2626
"""
2727

28-
2928
from __future__ import division
3029

3130
from base64 import b64encode
@@ -36,13 +35,13 @@
3635
from os.path import dirname, isfile
3736
from select import select
3837
from socket import create_connection, SHUT_RDWR, error as SocketError
39-
from struct import pack as struct_pack, unpack as struct_unpack, unpack_from as struct_unpack_from
38+
from struct import pack as struct_pack, unpack as struct_unpack
4039
from threading import RLock
4140

41+
from .compat.ssl import SSL_AVAILABLE, HAS_SNI, SSLError
4242
from .constants import DEFAULT_USER_AGENT, KNOWN_HOSTS, MAGIC_PREAMBLE, TRUST_DEFAULT, TRUST_ON_FIRST_USE
4343
from .exceptions import ProtocolError, Unauthorized, ServiceUnavailable
4444
from .packstream import Packer, Unpacker
45-
from .ssl_compat import SSL_AVAILABLE, HAS_SNI, SSLError
4645

4746

4847
# Signature bytes for each message type

neo4j/v1/ssl_compat.py renamed to neo4j/v1/compat/ssl.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
# See the License for the specific language governing permissions and
1919
# limitations under the License.
2020

21+
from __future__ import absolute_import
22+
2123
try:
2224
from ssl import SSLContext, PROTOCOL_SSLv23, OP_NO_SSLv2, CERT_REQUIRED, HAS_SNI, SSLError
2325
except ImportError:

0 commit comments

Comments
 (0)