Was this page helpful?
ScyllaDB Python Driver is available under the Apache v2 License. ScyllaDB Python Driver is a fork of DataStax Python Driver. See Copyright here.
Caution
You're viewing documentation for an unstable version of Scylla Python Driver. Switch to the latest stable version.
With ScyllaDB Cloud, you can deploy serverless databases. The Python driver allows you to connect to a serverless database by utilizing the connection bundle you can download via the Connect>Python tab in the Cloud application. The connection bundle is a YAML file with connection and credential information for your cluster.
Connecting to a ScyllaDB Cloud serverless database is very similar to a standard connection to a ScyllaDB database.
Here’s a short program that connects to a ScyllaDB Cloud serverless database and prints metadata about the cluster:
from cassandra.cluster import Cluster, ExecutionProfile, EXEC_PROFILE_DEFAULT
from cassandra.policies import DCAwareRoundRobinPolicy, TokenAwarePolicy
PATH_TO_BUNDLE_YAML = '/file/downloaded/from/cloud/connect-bundle.yaml'
def get_cluster():
profile = ExecutionProfile(
load_balancing_policy=TokenAwarePolicy(
DCAwareRoundRobinPolicy(local_dc='us-east-1')
)
)
return Cluster(
execution_profiles={EXEC_PROFILE_DEFAULT: profile},
scylla_cloud=PATH_TO_BUNDLE_YAML,
)
print('Connecting to cluster')
cluster = get_cluster()
session = cluster.connect()
print('Connected to cluster', cluster.metadata.cluster_name)
print('Getting metadata')
for host in cluster.metadata.all_hosts():
print('Datacenter: {}; Host: {}; Rack: {}'.format(
host.datacenter, host.address, host.rack)
)
cluster.shutdown()
By providing the scylla_cloud
parameter to the Cluster
constructor,
the driver can set up the connection based on the endpoint and credential information
stored in your downloaded ScyllaDB Cloud Serverless connection bundle.
Was this page helpful?
ScyllaDB Python Driver is available under the Apache v2 License. ScyllaDB Python Driver is a fork of DataStax Python Driver. See Copyright here.
cassandra
- Exceptions and Enumscassandra.cluster
- Clusters and Sessionscassandra.policies
- Load balancing and Failure Handling Policiescassandra.auth
- Authenticationcassandra.metadata
- Schema and Ring Topologycassandra.metrics
- Performance Metricscassandra.query
- Prepared Statements, Batch Statements, Tracing, and Row Factoriescassandra.pool
- Hosts and Connection Poolscassandra.protocol
- Protocol Featurescassandra.encoder
- Encoders for non-prepared Statementscassandra.decoder
- Data Return Formatscassandra.concurrent
- Utilities for Concurrent Statement Executioncassandra.connection
- Low Level Connection Infocassandra.util
- Utilitiescassandra.timestamps
- Timestamp Generationcassandra.io.asyncioreactor
- asyncio
Event Loopcassandra.io.asyncorereactor
- asyncore
Event Loopcassandra.io.eventletreactor
- eventlet
-compatible Connectioncassandra.io.libevreactor
- libev
Event Loopcassandra.io.geventreactor
- gevent
-compatible Event Loopcassandra.io.twistedreactor
- Twisted Event Loopcassandra.cqlengine.models
- Table models for object mappingcassandra.cqlengine.columns
- Column types for object mapping modelscassandra.cqlengine.query
- Query and filter model objectscassandra.cqlengine.connection
- Connection management for cqlenginecassandra.cqlengine.management
- Schema management for cqlenginecassandra.cqlengine.usertype
- Model classes for User Defined Types