Build Cloud-Native apps with Apache Cassandra

GOT QUESTIONS from the Workshop? You're in the right place! Post a question here and we'll get you answers.

Click here for Week 7 Materials and Homework.

Registrations still open!


question

ravee.o_193447 avatar image
ravee.o_193447 asked ·

How do I upload a CSV file to Astra?

How can we upload a CSV file to Astra so that we can copy the data to a Cassandra table?

workshopastra
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Erick Ramirez avatar image
Erick Ramirez answered ·

It sounds like you want to use the COPY FROM command in cqlsh to load data. DataStax Astra doesn't have VMs or cloud compute instances that you could upload files to. Astra is purely a Cassandra-as-a-service where the only service you have access to is a Cassandra database.

cqlsh

If you want to load data using the COPY FROM command, follow these steps:

Step A1 - Download the stand-alone cqlsh client.

Step A2 - Download the secure connect bundle for your Astra DB.

Step A3 - Unpack the standalone cqlsh tarball you downloaded:

$ tar xzf cqlsh-astra-*-bin.tar.gz

Step A4 - Connect to Astra with your login credentials and the secure connect bundle:

$ cd cqlsh-astra
$ bin/cqlsh -u astra_db_user -p astra_db_password -b /path/to/secure_connect_bundle_zip

From this session, you should be able to load the CSV file.

For more info, see Connecting to Astra databases using CQLSH.

DS Bulk Loader

As Alex Ott already mentioned, the preferred way for loading data is with the DataStax Bulk Loader tool. Follow these steps:

Step B1 - Download DSBulk.

Step B2 - Unpack the DSBulk tarball:

$ tar xzf dsbulk.tar.gz

Step B3 - Load data to a table as follows:

$ cd dsbulk-*
$ bin/dsbulk load -url /path/to/csv_file -k ks_name -t table_name \
    -u astra_db_user -p astra_db_password -b /path/to/secure_connect_bundle_zip

For more info, see Loading and unloading data with DataStax Bulk Loader for Astra.

There are also more examples of Loading data with DSBulk here. Cheers!

Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

alex.ott avatar image
alex.ott answered ·

You can use DSBulk to upload data to Astra (or upload data) - you need to specify path to secure bundle visa -b flag as described in documentation

Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.