Requirement
We want to load the data into snowflake using local files present in the desktop,
Require tools for file load.
- Snowflake account
- Snowsql installer.
- Sample CSV file.
Snowflake Account Overview
I am using trail version and its looks like below -
Account identifier is important that we need to login into snowsql. That you can get it from the Snowflake access URL as highlighted above.
Account Identifier = fzjlcwk-ns72307 (this is my account identifier; you will get new one)
Username and Password details when you create your login.
Create table in Snowflake
This table will hold the data when we load from csv.
CSV file
csv file having data with delimiter tab (\t) and which is defined in above when creating the table in snowflake.
Snowsql
Download the SnowSQL - SnowSQL - Snowflake Developers
As the file upload from local to snowflake is supported through command line and it is not supported using web api.
After installing the SnowSQL , open the command prompt in windows.
Verify its installed by running.
$snowsql -v
$snowsql -a <account identifier> -u <username>
It will prompt for password and after successful authentication it will show like below:-
Now you need to select the warehouse and database and schema where your table exists.
Three commands to execute to get to the location where your data load table is present.
USE WAREHOUSE <your_warehouse_name>;USE DATABASE <your_database>;USE SCHEMA <your_schema>;
Upload the file into stage by running below command: -
PUT file://C:\Prasad\Snowflake\csv_load.csv @%csv_table;
Data is loaded into the snowflake stage. Now we need to copy the data into destination table.
By running below copy command it will load the data into the required table.
COPY INTO csv_table;
Now data has been loaded into the table. We can validate by checking the table data in the worksheet.
So, we are successfully loaded the data into Snowflake.
No comments:
Post a Comment