Skip to content

Latest commit

 

History

History
116 lines (82 loc) · 3.53 KB

step1-astra.md

File metadata and controls

116 lines (82 loc) · 3.53 KB
Exploring Stargate with HTTPie ℹ️ For technical support, please contact us via email or LinkedIn.
⬅️ Back Step 1 of 3 Next ➡️ Tables in the REST API
Connect to Astra DB and create a database

Objectives In this step we will

  1. Create token
  2. Create database
  3. Create Credentials
  4. Verify Credentials

1. Create the token

✅ Create an application token with the Database Administrator role to access Astra DB. Skip this step if you already have a token.

2. Create the database

✅ Setup Astra CLI by providing the Database Administrator application token you created here:

astra setup

✅ Create database workshops and keyspace library if they do not exist:

astra db create workshops -k library --if-not-exist --wait

This operation may take a bit longer when creating a new database or resuming an existing hibernated database.

✅ Verify that database workshops is ACTIVE and keyspace library exists:

astra db get workshops

If the command fails, please revisit the previous steps to make sure that the database exists and is ACTIVE, and retry connecting to the database again.

HTTPie and Credentials

3. Create the credentials file

astra db create-dotenv -k library workshops

Now let's copy those credentials to our environment

python assets/set-environment.py .env workshops

4. Verify Credentials

Make a call to the API using httpie to make sure your credentials are working:

http --auth-type astra -a workshops: :/rest/v1/keyspaces

We've actually got an httpie config file so we can skip the auth-type stuff.

Try the simpler call to make sure it works:

http :/rest/v1/keyspaces
Show me the CQL
astra db cqlsh workshops -k library -e "desc keyspaces;"

Great, it's time to dive deeper into the Stargate APIs to see what they can do for you.

⬅️ Back - Overview Next ➡️ Tables in the REST API