How to export data to local system from snowflake cloud data warehouse?

Jeevan Krishna picture Jeevan Krishna · May 21, 2015 · Viewed 6.9k times · Source

I am using snowflake cloud datawarehouse, which is like teradata that hosts data. I am able run queries and get results on the web UI itself. But I am unclear how can one export the results to a local PC so that we can report based on the data.

Thanks in advance

Answer

Olivier Miranda picture Olivier Miranda · Jun 4, 2015

You have 2 options which both use sfsql which is based on henplus. The first option is to export the result of your query to a S3 staging file as shown below:

CREATE STAGE my_stage URL='s3://loading/files/' CREDENTIALS=(AWS_KEY_ID=‘****' AWS_SECRET_KEY=‘****’);
COPY INTO @my_stage/dump
FROM  (select * from orderstiny limit 5) file_format=(format_name=‘csv' compression=‘gzip'');

The other option is to capture the sql result into a file.

test.sql:

set-property column-delimiter ","; 
set-property sql-result-showheader off;
set-property sql-result-showfooter off;

select current_date() from dual;

$ ./sfsql < test.sql > result.txt

For more details and help, login to your snowflake account and access the online documentation or post your question to Snowflake support via the Snowflake support portal which is accessible through the Snowflake help section. Help -> Support Portal.

Hope this helps.