Exporting data from Cassandra to CSV file

Table name: Product

uid                                  | productcount | term                 | timestamp

304ad5ac-4b6d-4025-b4ea-8b7991a3fe72 |           26 |                dress | 1433110980000
6097e226-35b5-4f71-b158-a1fe39a430c1 |            0 |              #751104 | 1433861040000

      

Command:

COPY product (uid, productcount, term, timestamp) TO 'temp.csv';

      

Mistake:

Improper COPY command.

      

Am I missing something?

+3


source to share


2 answers


The syntax for your original COPY command is fine too. The problem lies in your column called timestamp, which is a datatype and is a reserved word in this context. For this reason, you need to escape the column name like this:

COPY product (uid, productcount, term, "timestamp") TO 'temp.csv';

      



Better yet, try using a different field name because it can cause other problems as well.

+3


source


I can export data to CSV files using the following command. Avoiding column names did the trick.



copy product to 'temp.csv' ;

      

+1


source







All Articles