Prerequisites
-
CLI Tool Installation:
- Install SnowSQL
- Install SnowCLI
-
Enable sample database
-
Using the sample database
-
Steps
Delete and recreate working directory
#rm -rf ~/work/temp/upload
mkdir -p ~/work/temp/upload
Create a new database using SnowSQL
snow sql -q 'create or replace database sandbox';
Create a new stage
snow object stage create sandbox.public.my_stage;
Unload data to the stage in the specified format
snow sql -q 'copy into @sandbox.public.my_stage/data.csv from (select * from SNOWFLAKE_SAMPLE_DATA.TPCH_SF1.LINEITEM limit 1000) file_format = (format_name = CSV_FORMAT compression = NONE) SINGLE=TRUE HEADER=TRUE OVERWRITE = TRUE';
Display the list of files in the stage
snow object stage list @sandbox.public.my_stage
Copy files from stage to local directory
cd ~/work/temp/upload
snow object stage copy @sandbox.public.my_stage .
Upload files from local to stage (using SnowCLI)
snow object stage copy data.csv @sandbox.public.my_stage
Upload local files to stage (using SnowSQL)
Login omitted
use database sandbox;
put file://~/work/temp/upload/* @my_stage;