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!
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
6 People are following this question.
Why can't I rename the keyspace on my Astra database?
Feedback on week 2 workshop notebook
Getting NPE in the Data Modeling notebook of the week 2 workshop
For people from India, which region should we choose in Astra ?
Why is the video_recommendations table missing from the week 2 workshop notebook?
DataStax Enterprise is powered by the best distribution of Apache Cassandra ™
© 2022 DataStax, Titan, and TitanDB are registered trademarks of DataStax, Inc. and its subsidiaries in the United States and/or other countries.
Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries.
Privacy Policy Terms of Use