Skip to content

Commit 8d64851

Browse files
committed
Minor documentation improvements
1 parent 2d77ee8 commit 8d64851

File tree

2 files changed

+41
-36
lines changed

2 files changed

+41
-36
lines changed

docs/getting_started.rst

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,35 @@ behavior in some other way, this is the place to do it:
4040

4141
.. code-block:: python
4242
43-
from cassandra.cluster import Cluster, ExecutionProfile, EXEC_PROFILE_DEFAULT
44-
from cassandra.query import tuple_factory
43+
from cassandra.cluster import Cluster
44+
cluster = Cluster(['192.168.0.1', '192.168.0.2'], port=..., ssl_context=...)
4545
46-
profile = ExecutionProfile(row_factory=tuple_factory)
47-
cluster = Cluster(execution_profiles={EXEC_PROFILE_DEFAULT: profile})
46+
Instantiating a :class:`~.Cluster` does not actually connect us to any nodes.
47+
To establish connections and begin executing queries we need a
48+
:class:`~.Session`, which is created by calling :meth:`.Cluster.connect()`:
49+
50+
.. code-block:: python
51+
52+
cluster = Cluster()
4853
session = cluster.connect()
4954
50-
print(session.execute("SELECT release_version FROM system.local").one())
55+
The :meth:`~.Cluster.connect()` method takes an optional ``keyspace`` argument
56+
which sets the default keyspace for all queries made through that :class:`~.Session`:
57+
58+
.. code-block:: python
59+
60+
cluster = Cluster()
61+
session = cluster.connect('mykeyspace')
62+
63+
64+
You can always change a Session's keyspace using :meth:`~.Session.set_keyspace` or
65+
by executing a ``USE <keyspace>`` query:
66+
67+
.. code-block:: python
68+
69+
session.set_keyspace('users')
70+
# or you can do this instead
71+
session.execute('USE users')
5172
5273
Profiles are passed in by ``execution_profiles`` dict.
5374

@@ -83,33 +104,6 @@ Users are free to setup additional profiles to be used by name:
83104
84105
Also, parameters passed to ``Session.execute`` or attached to ``Statement``\s are still honored as before.
85106

86-
Instantiating a :class:`~.Cluster` does not actually connect us to any nodes.
87-
To establish connections and begin executing queries we need a
88-
:class:`~.Session`, which is created by calling :meth:`.Cluster.connect()`:
89-
90-
.. code-block:: python
91-
92-
cluster = Cluster()
93-
session = cluster.connect()
94-
95-
The :meth:`~.Cluster.connect()` method takes an optional ``keyspace`` argument
96-
which sets the default keyspace for all queries made through that :class:`~.Session`:
97-
98-
.. code-block:: python
99-
100-
cluster = Cluster()
101-
session = cluster.connect('mykeyspace')
102-
103-
104-
You can always change a Session's keyspace using :meth:`~.Session.set_keyspace` or
105-
by executing a ``USE <keyspace>`` query:
106-
107-
.. code-block:: python
108-
109-
session.set_keyspace('users')
110-
# or you can do this instead
111-
session.execute('USE users')
112-
113107
Executing Queries
114108
-----------------
115109
Now that we have a :class:`.Session` we can begin to execute queries. The simplest

docs/security.rst

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ SSL Configuration Examples
9999
^^^^^^^^^^^^^^^^^^^^^^^^^^
100100
Here, we'll describe the server and driver configuration necessary to set up SSL to meet various goals, such as the client verifying the server and the server verifying the client. We'll also include Python code demonstrating how to use servers and drivers configured in these ways.
101101

102-
**No identity verification**
102+
.. _ssl-no-identify-verification:
103+
104+
No identity verification
105+
++++++++++++++++++++++++
103106

104107
No identity verification at all. Note that this is not recommended for for production deployments.
105108

@@ -123,7 +126,10 @@ The driver configuration:
123126
cluster = Cluster(['127.0.0.1'], ssl_context=ssl_context)
124127
session = cluster.connect()
125128
126-
**Client verifies server**
129+
.. _ssl-client-verifies-server:
130+
131+
Client verifies server
132+
++++++++++++++++++++++
127133

128134
Ensure the python driver verifies the identity of the server.
129135

@@ -166,7 +172,10 @@ Additionally, you can also force the driver to verify the `hostname` of the serv
166172
cluster = Cluster(['127.0.0.1'], ssl_context=ssl_context, ssl_options=ssl_options)
167173
session = cluster.connect()
168174
169-
**Server verifies client**
175+
.. _ssl-server-verifies-client:
176+
177+
Server verifies client
178+
++++++++++++++++++++++
170179

171180
If Cassandra is configured to verify clients (``require_client_auth``), you need to generate
172181
SSL key and certificate files.
@@ -229,8 +238,10 @@ Finally, you can use that configuration with the following driver code:
229238
cluster = Cluster(['127.0.0.1'], ssl_context=ssl_context)
230239
session = cluster.connect()
231240
241+
.. _ssl-server-client-verification:
232242
233-
**Server verifies client and client verifies server**
243+
Server verifies client and client verifies server
244+
+++++++++++++++++++++++++++++++++++++++++++++++++
234245
235246
See the previous section for examples of Cassandra configuration and preparing
236247
the client certificates.

0 commit comments

Comments
 (0)