LoginSignup
0
0

More than 3 years have passed since last update.

AWS Lambdaにpsycopg2でPython3.6からPostgreSQL へ接続

Last updated at Posted at 2020-04-10

Postgresインストール

非インストール版Zipファイルをダウンロード
https://www.enterprisedb.com/download-postgresql-binaries

command
initdb -D C:\pgsql\data -U xxxx
pg_ctl -D C:\pgsql\data  -l logfile start
createtable
psql.exe -d postgres -p 5432 -U xxxx
create database xxxxxx;
create table xxxxxx ........ ;

ビルド環境準備

pip更新

pip install --upgrade pip

必要なライブラリ

CentOS
$ yum install postgresql-devel
Debian/Ubuntu
$ apt-get install libpq-dev
MacOS
$ brew install postgresql

Lambdaデプロイパッケージ作成

psycopg2をインストール
cd sample
pip install psycopg2==2.7.1 -t ./
sampleフォルダー構成
lambda_function.py
psycopg2/

これを圧縮してZipファイルとしてLambdaにアップロードすることで完了。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0