This file contains 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
import pandas as pd | |
import requests | |
import configparser | |
import psycopg2 | |
# raw_data = requests.get("https://storage.googleapis.com/generall-shared-data/startups_demo.json") | |
# with open("raw_files/raw_data.json", "w") as f: | |
# f.write(raw_data.text) |
This file contains 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
import snowflake.snowpark as snowpark | |
from datetime import date | |
def create_stage(session: snowpark.Session, stage_name: str, s3_arn:str, aws_id:str, aws_secret:str): | |
query = "create or replace temporary stage {} url='{}' CREDENTIALS=(AWS_KEY_ID='{}' AWS_SECRET_KEY='{}')".format(stage_name, s3_arn, aws_id, aws_secret) | |
state = snowpark.Session.sql(self=session, query=query) | |
return state | |
def query_data(session: snowpark.Session, query: str, date: str): | |
table = snowpark.Session.sql(self=session, query=query) |
This file contains 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
#library import | |
import duckdb | |
import configparser | |
from duckdb.experimental.spark.sql import SparkSession as session | |
from duckdb.experimental.spark.sql.functions import col, when, lit | |
#read configs from secrets file | |
config = configparser.ConfigParser() | |
config.read('duck_db_demo/secrets.ini') | |
user = config['POSTGRES']['USER'] |