Compose Database-as-a-Service Help and Documentation

Everything you need to know about Compose, Hosted or Enterprise, is here in our help system. Whether you run one database for your businesses' sole application or six different databases to support an entire corporation, we've got the information you need.

Connecting to ScyllaDB

Connecting with cqlsh

The easiest way to verify your deployment and your tools is to connect directly using cqlsh. How you get this tool onto your local device will depend on your local platform. The easiest is to install the latest Cassandra release using an appropriate method for your platform (the latest versions still support version 2.1.8 which is what Scylla is) and use the builtin cqlsh

On a Mac, for example, you can install Cassandra with homebrew by typing brew install cassandra.

Copy any of the commands from the Compose console Overview page:

Example `cqlsh` connection string.

Example cqlsh connection string.

Paste the command into your shell to execute it:

The `cqlsh` shell.

The cqlsh shell.

If you type HELP you can see that the shell has a lot of capability. What's even nicer is that all of those commands have TAB completion too. Let's try it. Type CREATE KEYSPACE my_new_keyspace <TAB><TAB><TAB> you should see the choices for the replication class. Go ahead and choose SimpleStrategy since the cluster won't be spanning multiple data centers. Hit <TAB><TAB> again and enter in 3 for the replication_factor. Then close the brace with } and finish the statement with ;<enter>.

You just created your first KEYSPACE and defaulted it to replicating your data to all three nodes in your cluster.

Now that you have a keyspace let's use it:

USE my_new_keyspace;

Your shell now shows that your command prompt is using your keyspace by default:

Running `CREATE KEYSPACE` and `USE`.


Every table has to have a keyspace and when we create one in the shell here it will default to my_new_keyspace.

While Scylla/Cassandra has evolved into having a schema language that looks very similar to SQL. It's not really the case. Unlike an RDBMS, a row here is much more like a key value lookup. It just so happens that the value has a flexible schema which we are about to define:

Type the following CREATE TABLE command in the shell to create a place to populate with examples.

CREATE TABLE my_new_table (
  my_table_id uuid,
  last_name text,
  first_name text,
  PRIMARY KEY(my_table_id)

Connecting from the JVM

One of the most advanced drivers for Cassandra is the Java driver. This makes sense considering Cassandra is written in Java. What follows is a Groovy script. For those who utilize just about any JVM language translating from Groovy to your language of choice should be relatively straightforward:


import com.datastax.driver.core.BoundStatement
import com.datastax.driver.core.Cluster
import com.datastax.driver.core.Host
import com.datastax.driver.core.PreparedStatement
import com.datastax.driver.core.Row
import com.datastax.driver.core.Session

import static java.util.UUID.randomUUID

Cluster cluster = Cluster.builder()
        new InetSocketAddress("", 15399 ),
        new InetSocketAddress("", 15401 ),
        new InetSocketAddress("", 15400 )
    .withCredentials("scylla", "XOEDTTBPZGYAZIQD")

Session session = cluster.connect("my_new_keyspace")

PreparedStatement myPreparedInsert = session.prepare(
  """INSERT INTO my_new_table(my_table_id, last_name, first_name)
     VALUES (?,?,?)""")

BoundStatement myInsert = myPreparedInsert
    .bind(randomUUID(), "Hutton", "Hays")



To get started we pull in the latest Cassandra driver:


After all of the imports we use a Cluster.builder() to build up the configuration. Just one of the ContactPoints is used to connect. From that connection the other nodes in the cluster are discovered. If that ContactPoint is unreachable on connect then another is used which is why we add all three.

PreparedStatements may be familiar since they are analogous to other DBs' features of the same name. The statement is parsed and held at the server ready to be used over and over again. The following calls to bind and execute populate and send the data over to the server for actual execution. While there are simpler methods for one off execution, it is good to highlight such a useful feature.

To prove that the script works go back to your cqlsh and query the table:

Results from `SELECT` in `cqlsh`.

Results from SELECT in cqlsh.

Connecting from Python

Support for languages other than Java is very solid too. Python is a great example. cqlsh is even written in Python. So make no mistake the support here is more than up to date:

pip install cassandra-driver

This pulls in the driver with a python package manager pip. The following performs very similarly to the Java code of preparing a statement and executing an insert:

from cassandra.cluster import Cluster
from cassandra.auth import PlainTextAuthProvider
import uuid

auth_provider = PlainTextAuthProvider(

cluster = Cluster(
            contact_points = [""],
            port = 15401,
            auth_provider = auth_provider)

session = cluster.connect('my_new_keyspace')

my_prepared_insert = session.prepare("""
    INSERT INTO my_new_table(my_table_id, first_name, last_name)
    VALUES (?, ?, ?)""")

session.execute(my_prepared_insert, [uuid.uuid4(), 'Snake', 'Hutton'])

To verify again we'll run the same SELECT command:

Results from `SELECT` in `cqlsh`.

Results from SELECT in cqlsh.

Connecting from Node.js

Use node package manager (npm) to install the driver and the needed uuid library.

npm install cassandra-driver
npm install uuid

The code is similar to the previous examples:

var cassandra = require('cassandra-driver')
var authProvider = new cassandra.auth.PlainTextAuthProvider('scylla', 'XOEDTTBPZGYAZIQD')
var uuid = require('uuid')

client = new cassandra.Client({
                        contactPoints: [
                        keyspace: 'my_new_keyspace',
                        authProvider: authProvider});

client.execute("INSERT INTO my_new_table(my_table_id, first_name, last_name) VALUES(?,?,?)",
               [uuid.v4(), "V8", "Hutton"],
               { prepare: true },
               function(err, result) {
                 if(err) { console.error(err); }

Once again the code connects, and prepares and executes an insert statement. Verify the code with the SELECT command:

Results from `SELECT` in `cqlsh`.

Results from SELECT in cqlsh.

Still Need Help?

If this article didn't solve things, summon a human and get some help!

What's Next

Improve your connection reliability and resiliance with Address Translation maps

Address Translation Maps

Connecting to ScyllaDB