This is a custom compiled psycopg2 C library for Python 3. Due to AWS Lambda
missing the required PostgreSQL libraries in the AMI image, we needed to
compile psycopg2 with the PostgreSQL libpq.so
library statically linked
libpq library instead of the default dynamic link.
- psycopg2 2.7.7
- postgresql 10.7
- Python 3.7
Copy the psycopg2
folder in the build
folder into your AWS Lambda zip package.
Library needs to be compiled in amazon linux environment. Most likely you don't have the environment.
Solution? Docker!
- Install Docker.
- Download the
PostgreSQL source code (.tar.gz),
rename to postgresql.tar.gz and put it into
sources
folder. - Download the
psycopg2 source code (.tar.gz),
rename to psycopg2.tar.gz and put it into
sources
folder. - build image:
make build
- run image:
make run
- delete image if you don't need it anymore:
make clean
custom compiled psycopg2 library is now in build
folder.
- Change step 4 above to:
make build SSL=1
makefile
is not available on Windows, there're few options: