@@ -3,16 +3,42 @@ Getting Started
33
44First, make sure you have the driver properly :doc: `installed <installation >`.
55
6- Connecting to Cassandra
6+ Connecting to a Cluster
77-----------------------
88Before we can start executing any queries against a Cassandra cluster we need to setup
99an instance of :class: `~.Cluster `. As the name suggests, you will typically have one
1010instance of :class: `~.Cluster ` for each Cassandra cluster you want to interact
1111with.
1212
13- The simplest way to create a :class: `~.Cluster ` is like this:
1413First, make sure you have the Cassandra driver properly :doc: `installed <installation >`.
1514
15+ Connecting to Astra
16+ +++++++++++++++++++
17+
18+ If you are a DataStax `Astra <https://www.datastax.com/products/datastax-astra >`_ user,
19+ here is how to connect to your cluster:
20+
21+ 1. Download the secure connect bundle from your Astra account.
22+ 2. Connect to your cluster with
23+
24+ .. code-block :: python
25+
26+ from cassandra.cluster import Cluster
27+ from cassandra.auth import PlainTextAuthProvider
28+
29+ cloud_config = {
30+ ' secure_connect_bundle' : ' /path/to/secure-connect-dbname.zip'
31+ }
32+ auth_provider = PlainTextAuthProvider(username = ' user' , password = ' pass' )
33+ cluster = Cluster(cloud = cloud_config, auth_provider = auth_provider)
34+ session = cluster.connect()
35+
36+ See `Astra <https://docs.datastax.com/en/astra/aws/doc/index.html >`_ and :doc: `cloud ` for more details.
37+
38+ Connecting to Cassandra
39+ +++++++++++++++++++++++
40+ The simplest way to create a :class: `~.Cluster ` is like this:
41+
1642.. code-block :: python
1743
1844 from cassandra.cluster import Cluster
@@ -52,6 +78,8 @@ To establish connections and begin executing queries we need a
5278 cluster = Cluster()
5379 session = cluster.connect()
5480
81+ Session Keyspace
82+ ----------------
5583The :meth: `~.Cluster.connect() ` method takes an optional ``keyspace `` argument
5684which sets the default keyspace for all queries made through that :class: `~.Session `:
5785
@@ -60,7 +88,6 @@ which sets the default keyspace for all queries made through that :class:`~.Sess
6088 cluster = Cluster()
6189 session = cluster.connect(' mykeyspace' )
6290
63-
6491 You can always change a Session's keyspace using :meth: `~.Session.set_keyspace ` or
6592by executing a ``USE <keyspace> `` query:
6693
@@ -70,6 +97,8 @@ by executing a ``USE <keyspace>`` query:
7097 # or you can do this instead
7198 session.execute(' USE users' )
7299
100+ Execution Profiles
101+ ------------------
73102Profiles are passed in by ``execution_profiles `` dict.
74103
75104In this case we can construct the base ``ExecutionProfile `` passing all attributes:
0 commit comments