Snowflake Git Integration
In this tutorial we will show you how to integrate Git into your Snowflake account. We will walk through two main subjects. The first is pulling the repo into Snowflake and navigating around. The second is creating a stored procedure, streamlit dashboard, and run a query from files that lives on github.
Credit for the orginial tutorial goes to Mark Boos!
Video
Requirements
You will need a github repo and the ability to create a personal access token. We will show how to create the token in this tutorial.
Download
Setup
In this section we will upload the example code to a repository and then setup Snowflake:
Github Repository
Call it "tutorial". It can be public or private.
Please do not upload the repo folder itself. Just the files in it.
Upload the example repository.
Personal Access Token
We will need a persoanl access token to allow Snowflake to work with our Git repository. First lets navigate to the token page.
We'll be using a classic token.
Next we'll enter in a name, the experation of the token, and select "repo" for the scope of the permissions.
We'll copy our token, it will be used in the following Snowflake step.
Snowflake
Lets now use snowflake to connect to our repository.
If you don't have a database, schema or warehouse yet.
use role sysadmin;
-- Create a database to store our schemas.
create database raw;
-- Create the schema. The schema stores all our objectss.
create schema raw.git;
/*
Warehouses are synonymous with the idea of compute
resources in other systems. We will use this
warehouse to call our user defined function.
*/
create warehouse if not exists developer
warehouse_size = xsmall
initially_suspended = true;
use database raw;
use schema git;
use warehouse developer;
status |
---|
Git Repository TUTORIAL was successfully created. |
Examples
Now that we have our Snowflake and Git repository setup lets go through a few examples.
Navigation
Lets navigate and show parts of our repo in Snowflake.
Run a File
Lets execute a file on Snowflake that lives in our repositroy.
Stored Procedure
Lets create a snowflake stored procedure from a file that lives in the repository.
Streamlit
Lets create a Streamlit application in Snowflake using a file in our repository.
Lets navigate to the streamlit in snowflake tab and select our dashboard that we just created.
Look at our simple streamlit dashboard that was create from our file in our Git repository!