AWS Lambda Layers Python | Snowflake-lambda-layer

Veröffentlicht am: 08 Oktober 2021
auf dem Kanal: Knowledge Amplifier
7,351
89

In this video , I discussed about Lambda Layer , which is kind of an external library that can be directly included, and used in the Lambda function.
Hope this video will be helpful to you!

Lambda Layer Creation Code:
-----------------------------------------------
sudo apt-get update
sudo apt install python3-virtualenv
virtualenv snowflake_test
source snowflake_test/bin/activate
python3 --version
sudo apt install python3-pip
python3 -m pip install --upgrade pip
sudo apt-get install -y libssl-dev libffi-dev
mkdir -p lambda_layers/python/lib/python3.8/site-packages
cd lambda_layers/python/lib/python3.8/site-packages
pip install -r https://raw.githubusercontent.com/sno... -t .
pip install snowflake-connector-python==2.3.10 -t .
cd ~/lambda_layers
sudo apt install zip
zip -r snowflake_lambda_layer.zip *

The zip used in the lambda layer can be downloaded form this link also:
https://drive.google.com/file/d/1ZG58...

Lambda Function used:
--------------------------------------
import snowflake.connector as sf

def run_query(conn, query):
cursor = conn.cursor()
cursor.execute(query)
cursor.close()

def lambda_handler(event, context):
user=""
password=""
account="";
database=""
warehouse=""
schema=""
role=""
conn=sf.connect(user=user,password=password,account=account);


statement_1='use warehouse '+warehouse;
statement3="use database "+database;
statement4="use role "+role;
run_query(conn,statement_1)
run_query(conn,statement3)
run_query(conn,statement4)
sql_query_table_creation = "CREATE OR REPLACE TABLE test_table(col1 integer, col2 string)"
run_query(conn, sql_query_table_creation);
sql_query_data_ingestion="INSERT INTO test_table(col1, col2) VALUES (123, 'test string1'), (456, 'test string2')"
run_query(conn, sql_query_data_ingestion);


Check this playlist for more AWS Projects in Big Data domain:
   • Demystifying Data Engineering with Cloud C...  


Auf dieser Seite können Sie das Online-Video AWS Lambda Layers Python | Snowflake-lambda-layer mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Knowledge Amplifier 08 Oktober 2021 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 7,351 Mal angesehen und es wurde von 89 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!