Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Unable to create keyspace with the Python driver, getting Unauthorized error "Missing correct permission"

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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")

>Solution :

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!

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading