Best way to export YCQL data

What is the recommended tool/procedure to export data from a YCQL table into say, CSV format?

Sorry! I read “YSQL” when I saw your “YCQL”. You might be interested in an answer to a question that you didn’t ask.

Easy [for YSQL]: use the \copy meta-command at the ysqlsh prompt. Look:

drop table if exists t;
create table t (
  id integer generated always as identity primary key,
  c1 text);
insert into t(c1) values
  ('dog'),
  ('cat'),
  ('mouse'),
  ('Norwegian Blue');
\copy t to 't.txt' (format 'csv')

Here’s the t.txt that I got:

1,dog
4,Norwegian Blue
2,cat
3,mouse

And here’s the grammar:

\copy { table [ ( column_list ) ] | ( query ) } { from | to } { 'filename' | program 'command' | stdin | stdout | pstdin | pstdout } [ [ with ] ( option [, ...] ) ]

Regards, bryn@yugabyte.com

1 Like

Hi @adam.afloat,

For YCQL this doc page should help (see the last section on data export):

Also, here is the github page which also has a lot of information:

1 Like