Sign inGet started
← Back to all guides

How to connect to Snowflake using SQLAlchemy

By Nick Barth

Updated on March 6, 2024

To connect to Snowflake using SQLAlchemy, you will need to install the Snowflake SQLAlchemy package and then set up your connection URI with your Snowflake account details. The URI typically includes your user, password, account, warehouse, database, and schema information. Below is a step-by-step guide expressed in Markdown:

  1. Install the Snowflake SQLAlchemy package by running:
pip install snowflake-sqlalchemy

2. Create a connection URI in the following format:

snowflake://<USER>:<PASSWORD>@<ACCOUNT_IDENTIFIER>/<DATABASE_NAME>/<SCHEMA_NAME>?warehouse=<WAREHOUSE>&role=<ROLE>

3. Use the URI to create an engine using SQLAlchemy:

from sqlalchemy import create_engine
engine = create_engine('<YOUR_CONNECTION_URI>')  

4. Now you can use the engine to execute queries against your Snowflake database.

connection = engine.connect()
results = connection.execute("SELECT * FROM your_table").fetchall()
connection.close()

Please ensure you replace `<YOUR_CONNECTION_URI>` with the actual connection URI created in step 2.

That’s it, time to try Deepnote

Get started – it’s free
Book a demo

Footer

Product

  • Integrations
  • Pricing
  • Documentation
  • Changelog
  • Security

Company

Comparisons

Resources

  • Privacy
  • Terms

© Deepnote