Use PostgreSQL with Lambda (Python + psycopg2)

Introduction

An easy way to use PostgreSQL with psycopg2 when using Python with Lambda. Until now, importing psycopg2 has been a hassle.

Method

I will use Mischa Spiegelmock's Lambda layer.

https://github.com/jetbridge/psycopg2-lambda-layer

Lambda3.8 Tokyo Region ap-northeast-1

arn:aws:lambda:ap-northeast-1:898466741470:layer:psycopg2-py38:1

スクリーンショット 2020-09-04 0.06.19.png

If you specify arn for the layer, it's OK. You can import with just this!

At the end

It was easy to build from Code on Github and make it a layer.

reference

Qiita: Before creating a layer of Python external library on AWS Lambda https://qiita.com/polarbear08/items/202752d5ffcb65595bd9

Recommended Posts

Use PostgreSQL with Lambda (Python + psycopg2)
Use mecab with Python3
Use DynamoDB with Python
Use Python 3.8 with Anaconda
Use python with docker
Use Trello API with python
Use Twitter API with Python
Use TUN / TAP with Python
Use subsonic API with python3
How to use Python lambda
Python: How to use async with
Use PointGrey camera with Python (PyCapture2)
Use vl53l0x with Raspberry Pi (python)
Face detection with Lambda (Python) + Rekognition
Use NAIF SPICE TOOLKIT with Python
Use rospy with virtualenv in Python3
How to use FTP with Python
Use Windows 10 speech synthesis with Python
Use OpenCV with Python 3 in Window
Notify HipChat with AWS Lambda (Python)
[AWS] Using ini files with Lambda [Python]
Use print in a Python2 lambda expression
[Note] Get data from PostgreSQL with Python
Use smbus with python3 under pyenv environment
Use PostgreSQL data type (jsonb) from Python
Use Amazon Simple Notification Service with Python
[Python] Use string data with scikit-learn SVM
[Introduction to Python] Let's use foreach with Python
Use PIL and Pillow with Cygwin Python
Use cryptography library cryptography with Docker Python image
Manipulate DynamoDB data with Lambda (Node & Python)
Connect to s3 with AWS Lambda Python
Use C ++ functions from python with pybind11
Load AWS-RDS / PostgreSQL tables with AWS-Lambda + Python
Use selenium phantomjs webdriver with python unittest
Until you can use opencv with python
Use Python and MeCab with Azure Functions
Try assigning or switching with Python: lambda
Python + Selenium + Headless Chromium with aws lambda
ImportError when trying to use gcloud package with AWS Lambda Python version
Statistics with python
Python with Go
Twilio with Python
Integrate with Python
Play with 2016-Python
AES256 with python
Tested with Python
python starts with ()
with syntax (Python)
Bingo with python
Zundokokiyoshi with python
Excel with Python
Microcomputer with Python
Cast with python
AWS-Perform web scraping regularly with Lambda + Python + Cron
Use additional Python packages with Serverless Framework (v1.x)
Specify the Python executable to use with virtualenv
Achieve Basic Authentication with CloudFront Lambda @ Edge with Python 3.8
Play with Lambda layer (python) for about 5 minutes
Use logger with Python for the time being
Python> Run with run-time arguments> Use import argparse