Step 5: Run the cqlsh COPY FROM command to upload data from the CSV file to the target table
To run the cqlsh COPY FROM command, complete the following steps.
-
Connect to Amazon Keyspaces using cqlsh.
-
Choose your keyspace with the following code.
USEcatalog; -
Set write consistency to
LOCAL_QUORUM. To ensure data durability, Amazon Keyspaces doesn’t allow other write consistency settings. See the following code.CONSISTENCY LOCAL_QUORUM; -
Prepare your
cqlsh COPY FROMsyntax using the following code example.COPYbook_awardsFROM './keyspace.table.csv' WITH HEADER=true AND INGESTRATE=calculated ingestrateAND NUMPROCESSES=calculated numprocessAND MAXBATCHSIZE=20 AND CHUNKSIZE=calculated chunksize; -
Run the statement prepared in the previous step. cqlsh echoes back all the settings that you've configured.
-
Make sure that the settings match your input. See the following example.
Reading options from the command line: {'chunksize': '120', 'header': 'true', 'ingestrate': '36000', 'numprocesses': '15', 'maxbatchsize': '20'} Using 15 child processes -
Review the number of rows transferred and the current average rate, as shown in the following example.
Processed: 57834 rows; Rate: 6561 rows/s; Avg. rate: 31751 rows/s -
When cqlsh has finished uploading the data, review the summary of the data load statistics (the number of files read, runtime, and skipped rows) as shown in the following example.
15556824 rows imported from 1 files in 8 minutes and 8.321 seconds (0 skipped).
-
In this final step of the tutorial, you have uploaded the data to Amazon Keyspaces.
Important
Now that you have transferred your data, adjust the capacity mode settings of your target table to match your application’s regular traffic patterns. You incur charges at the hourly rate for your provisioned capacity until you change it.