1

I am trying to create a keyspace on my `Astra' instance but I have gotten this error while trying the execute the CREATE statement:

---------------------------------------------------------------------------
Unauthorized                              Traceback (most recent call last)
/home/ryan/Documents/is3107-2/project/connect-to-db.ipynb Cell 2 in <cell line: 1>()
----> 1 session.execute('''
      2 CREATE KEYSPACE IF NOT EXISTS dblp
      3 WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 3};
      4 ''')
      6 session.set_keyspace("dblp")

File ~/anaconda3/envs/is3107/lib/python3.9/site-packages/cassandra/cluster.py:2618, in cassandra.cluster.Session.execute()

File ~/anaconda3/envs/is3107/lib/python3.9/site-packages/cassandra/cluster.py:4894, in cassandra.cluster.ResponseFuture.result()

Unauthorized: Error from server: code=2100 [Unauthorized] message="Missing correct permission on dblp."

This error reoccurs when I ran the same CQL statement on Astra CQL console tab.

Here are the codes:

from cassandra.cluster import Cluster
from cassandra.auth import PlainTextAuthProvider
client_id = .....
secret = ....
cloud_config= {
         'secure_connect_bundle': '/home/ryan/Documents/is3107-2/project/secure-connect-is3107-project-by-ng-guangren-ryan.zip'
}
auth_provider = PlainTextAuthProvider(client_id,secret)
cluster = Cluster(cloud=cloud_config, auth_provider=auth_provider)
session = cluster.connect()

row = session.execute("select release_version from system.local").one()
if row:
      print(row[0])
else:
      print("An error occurred.")
#Returned row[0] with the IP address


session.execute('''
CREATE KEYSPACE IF NOT EXISTS dblp
WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 3};
''')

session.set_keyspace("dblp")

1
  • 1
    Erick is right about keyspaces in Astra; just not possible. Trust me, that’s a good thing. Schema changes made from the app side cause more than their fair share of trouble. Commented Oct 21, 2022 at 2:04

1 Answer 1

4

It is not possible to create a keyspace programatically or via cqlsh with Astra DB.

To add a new keyspace, you need to logon to the Astra DB web UI and on the Dashboard, select your database then click on the Add Keyspace button:

Astra web UI

Alternatively, you can also create a new keyspace using the Astra DevOps API.

For details, see Managing multiple keyspaces in Astra DB. Cheers!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.