Loading data into snowflake table using snowsql client- CNDRO.LLC
2731
post-template-default,single,single-post,postid-2731,single-format-standard,wp-custom-logo,theme-bridge,bridge-core-2.9.4,woocommerce-no-js,tribe-no-js,ehf-template-bridge,ehf-stylesheet-bridge-child,qode-page-transition-enabled,ajax_fade,page_not_loaded,,qode-title-hidden,qode_grid_1300,footer_responsive_adv,hide_top_bar_on_mobile_header,columns-4,qode-child-theme-ver-1.0.0,qode-theme-ver-27.8,qode-theme-bridge,qode_header_in_grid,wpb-js-composer js-comp-ver-6.7.0,vc_responsive,elementor-default,elementor-kit-2634

Loading Data into Snowflake Table using SnowSQL Client

Recently, Snowflake has gained momentum in the cloud data warehousing space. Snowflake offers a cloud-based data storage and analytics service, generally known as “data warehouse-as-a-service”. It lets corporate users store and analyze data using cloud-based hardware and software. Snowflake table stores data and there are three types namely: permanent, transient, and transient table. Snowsql is a command-line client used to connect to Snowflake to execute SQL queries and perform all DDL and DML operations. These operations include loading data into and unloading data out of database tables.

You might be wondering how you can transfer data from your local machine into Snowflake. There are a few ways to load data from your computer into the Snowflake table but we would be using Snowsql in this article. Let’s jump right into it.

To use Snow SQL you will need to install it on your PC.

You can download SnowSQL for your platform from the Snowflake repository. It is available for Windows, Linux, and macOS.

Below is the index of SnowSQL

After you have run the windows installer, open your CMD as an administrator and finish the installation on CMD using snowsql -v .

Use the Snowsql Client to ingest the CSV data into the Snowflake Stage area

Then log in to Snowflake using the following;

snowsql -a accountName -u userName

In my case I have;

snowsql -a dja65956.us-east-1 -u omolayo

Provide your password. Select the database with the line of code:

USE DATABASE YOURDATABASENAME;
In my case, I have USE DATABASE TESTING_DB;

The next step is to upload the data from your local computer to the snowflake database stage using this;

PUT file://C:\Users\Omolayo\Documents\CndroData\SnowflakeDatatesting.csv @cndro_stage;

After you have run the windows installer, open your CMD as an administrator and finish the installation on CMD using snowsql -v .

Use the Snowsql Client to ingest the CSV data into the Snowflake Stage area

Then log in to Snowflake using the following;

snowsql -a accountName -u userName

In my case I have;

snowsql -a dja65956.us-east-1 -u omolayo

Provide your password. Select the database with the line of code:

USE DATABASE YOURDATABASENAME;

In my case I have USE DATABASE TESTING_DB;

The next step is to upload the data from your local computer to the snowflake database stage using this;

PUT file://C:\Users\Omolayo\Documents\CndroData\SnowflakeDatatesting.csv @cndro_stage;

The data should look like this;

The screenshot below shows the communication between your computer and your snowflake cloud console.
Use the Snowflake console to copy the data into the table you have created using the SQL code below.
COPY INTO TESTING
FROM @cndro_stage
FILE_FORMAT = (type = csv field_optionally_enclosed_by=’”’)
PATTERN = ‘.*SnowflakeDatatesting.csv.gz’
ON_ERROR = ‘skip_file’;

You should have your table like this. We are working on the worksheet’s editor console, please see the screenshot.

Final Thoughts

In today’s guide, we walked through how you can load data into Snowflake table using SnowSQL Client. Kindly share and follow for more articles.
Thanks for reading and see you next time.

No Comments

Post A Comment