Skip to content

Instantly share code, notes, and snippets.

View umjohndacosta's full-sized avatar

John DaCosta umjohndacosta

  • Fort Lauderdale, FL
View GitHub Profile
@umjohndacosta
umjohndacosta / 64500277-snowflake-working-with-stored-procedure-on-error-handling.sql
Created July 11, 2021 01:08
stackoverflow-64500277-snowflake-working-with-stored-procedure-on-error-handling
CREATE OR REPLACE SCHEMA abc;
USE SCHEMA ABC;
CREATE SEQUENCE IF NOT EXISTS EXECUTION_SEQUENCE
WITH
START WITH = 1
INCREMENT BY = 1
COMMENT = 'DEMO SEQUENCE ' ;
-- https://stackoverflow.com/questions/68322927/calculating-yoy-revenue-when-not-all-accounts-existed-last-year
create or replace table arr_base(account_id varchar, account_name varchar, activity_date date, arr number(32,4));
insert into arr_base (account_id, account_name, activity_date, arr)
values
('A','ACCOUNT A','2021-01-31',50)
,('B','ACCOUNT B','2021-01-31',40)
# https://stackoverflow.com/questions/68323279/writing-dataframe-to-snowflake-error-binding-data-in-type-timestamp-is-not-su
# https://community.snowflake.com/s/question/0D50Z00009UB5aPSAT/how-to-connect-using-sqlalchemy-with-okta-idp
import pandas as pd
import sqlalchemy as sa
from sqlalchemy import *
import snowflake.connector
# pip install --upgrade snowflake-sqlalchemy pandas
# pip install --upgrade snowflake-connector-python
use warehouse WH_TEST;
use database DB_TEST;
use schema public;
/*
create or replace table calendar(calendar_date DATE)
insert into calendar(calendar_date)
select