The requred pacakges include the snowflake connector and the pandas-compatable version of the snowflake connector, these can be installed using:
pip install "snowflake-connector-python[secure-local-storage,pandas]"
For more code examples and further instructions, head to the DotPi webpage for connecting Python to Snowflake http://dot-pi.com/connect-python-to-s...
The code used in this video is pasted below
#import the snowflake connector
import snowflake.connector
#open a database connection
ctx = snowflake.connector.connect(
user = USERNAME
password = PASSWORD
account= ACCOUNT
region = REGION
Role = ROLE (Optional)
Warehouse = WAREHOUSE (Optional)
)
#create a cursor object
cs = ctx.cursor()
city = 'Christchurch'
sql_query = '''
SELECT *
FROM "ExampleDB"."EXAMPLESCHEMA"."EXAMPLEWEATHERDATA"
WHERE "CITY" = ''' + "'" + city + "'"
cs.execute(sql_query)
#convert the data to a pandas dataframe
data_df = cs.fetch_pandas_all()
Watch video Connect Python to Snowflake (with password and external authentication) online without registration, duration hours minute second in high quality. This video was added by user DotPi 25 March 2022, don't forget to share it with your friends and acquaintances, it has been viewed on our site 11,53 once and liked it 8 people.