본문 바로가기
Data/Data Engineering

[Snowflake] Snowflake-python 연결 (Snowflake를 Python으로 사용하는 방법. Snowflake Connector for Python)

by DenverAlmighty 2024. 3. 6.
반응형

 

실행

. ./venv/bin/activate

pip install snowflake-connector-python
pip install "snowflake-connector-python[pandas]"

 

Snowflake Connector for Python

 

// models.py

import os
import snowflake.connector
AWS_ACCESS_KEY_ID = os.getenv('<KEY_ID>')
AWS_SECRET_ACCESS_KEY = os.getenv('<ACCESS_KEY>')

conn = snowflake.connector.connect(
    user='<USER>',
    password='<PW>',
    account='<ACCOUNT>'
)

cs = conn.cursor()

def getTestDataAll() :
    query = "<SELECT * FROM IRON_S3.PUBLIC.TEST_TABLE>"
    data = conn.cursor().execute(query) 
    data_df = data.fetch_pandas_all()
    print(data_df)
    return data_df

 

 

결과

728x90
반응형