1 0
Read Time:1 Minute, 22 Second

During this post we will discuss how to access data stored in Snowflake via Python REST API. In our Python code will use FLASK API to get Snowflake data. Consider the case where web applications often want to retrieve that data through http APIs. This API consists of reporting endpoints from data stored in Snowflake. We will hit the API from URL with query as parameter. This will route to the tag defined in the python code. Query Executes and in response returns the JSON data. We have transformed this JSON response into Dictionary.

So we will learn :

  • How to configure and build a custom API Powered by Snowflake
  • How to test and monitor the API

Also I tried to connect the Snowflake via two approaches:

  • Using Snowflake.connector as sf
  • Using sqlalchemy Engine.

To develop the same following connectors has been imported/installed on your environment.

import pandas as pd
import json
import sqlalchemy
import snowflake.connector as sf
from snowflake.sqlalchemy import URL
from sqlalchemy import create_engine
from flask import Flask,request


Please find below the technical implementation of Python Code:

Note: engine and conn are used to connect with snowflake via Sqlalchemy and Snowflake connector respectively.

Connect via sql Alchemy and Snowflake connector:

Snowflake Connector

Define the REST API end point to hit the snowflake and retrieve the response in JSON.

Code Run


Output Pandas



Average Rating

5 Star
4 Star
3 Star
2 Star
1 Star

Leave a Reply

Your email address will not be published. Required fields are marked *