This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Connecting to Snowflake | |
import snowflake.connector | |
ctx = snowflake.connector.connect( | |
user='emilegill', | |
password='XXXX', | |
account='XXXX') | |
cs = ctx.cursor() | |
try: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Load data into table | |
copy into worldwide_cases | |
from @test_db.public.test_stage | |
file_format = ( | |
type = csv | |
skip_header=1 | |
error_on_column_count_mismatch = false | |
field_optionally_enclosed_by='"'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- List files in stage | |
ls @test_db.public.test_stage; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
put file://C:\Users\emile\OneDrive\Documents\GitHub\snowflake-basics\ecdc_covid_cases.csv @test_db.public.test_stage; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Create Internal Stage | |
create or replace stage test_stage; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Create External Stage | |
create or replace stage test_external_stage | |
url = 's3://<bucket>[/<path>/]' | |
credentials = (aws_key_id='XXXX' aws_secret_key='XXXX'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Create Table | |
create or replace table worldwide_cases ( | |
date_rep string, | |
day string, | |
month string, | |
year string, | |
cases number, | |
deaths number, | |
countries_and_territories string, | |
geo_id string, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Check current context | |
select current_warehouse(), current_database(), current_schema() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Create Database | |
create or replace database test_db; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Create Virtual Warehouse | |
create or replace warehouse test_wh with | |
warehouse_size="X-SMALL" | |
auto_suspend=180 | |
auto_resume=true | |
initially_suspended=true; |
NewerOlder