How to Deploy Python Flask Application on AWS EC2

preview_player
Показать описание
Prerequisite:
---------------------
Expose Snowflake Data by creating Python API

Installations:
--------------------

sudo apt-get update
sudo apt install python3-virtualenv
virtualenv snowflake_test
source snowflake_test/bin/activate
python3 --version
python -m pip install --upgrade pip
pip install snowflake-connector-python==2.6.2 -t .
pip install pandas -t .
pip install "snowflake-connector-python[pandas]" -t .
pip install flask -t .

Code:
--------
import pandas as pd
import json

from flask import Flask,request

app=Flask(__name__)

user=""
password=""
account=""
database=""
warehouse=""
schema=""
role=""

statement_1='use warehouse '+warehouse
statement2='alter warehouse '+warehouse+" resume"
statement3="use database "+database
statement4="use role "+role

def run_query(conn, query):
print("Executing the {} query".format(query))
try:
except Exception as e:
print(e)

def run_query1(conn, query):
return records

def hello_world():
return "Hello World , Welcome to Snowflake API"

def stats_collector():
extracted_data=run_query1(conn, query_to_be_executed)
print(extracted_data)
return extracted_data

def data_extractor():

if __name__=='__main__':
run_query(conn, statement_1)
run_query(conn, statement2)
run_query(conn, statement3)
run_query(conn, statement4)

Run the code:
-----------------------

To create tmux session:
-----------------------------------------
source snowflake_test/bin/activate

sudo apt-get install tmux
tmux new -s flaskapidemo
Ctrl+B and then D

To kill tmux session:
-----------------------------------
tmux list-sessions
tmux kill-session -t targetSession
(in this case , tmux kill-session -t flaskapidemo)

Check this playlist for more AWS Projects or POC in Big Data domain:
Рекомендации по теме
Комментарии
Автор

It is very easy to follow your explanation. It is better than Snowflake documentation

moizdewaswala
Автор

Bro you are genius.. you saved my lot of time...much thanks!
keep creating such content.😍

akshaysnimbalkar