How can we upload a CSV file to Astra so that we can copy the data to a Cassandra table?
GOT QUESTIONS from the Workshop? You're in the right place! Post a question here and we'll get you answers.
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.
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.
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!
6 People are following this question.