Skip to main content

psycopg2 Python Library for AWS Lambda

This is a custom compiled psycopg2 C library for Python. 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.I am just using the follwing git source and uploaded to https://pypi.org/

Install and setup

pip install aws-psycopg2

Source code : https://github.com/jkehler/awslambda-psycopg2/tree/master/psycopg2

Instructions on compiling this package from scratch

Here was the process that was used to build this package. You will need to perform these steps if you want to build a newer version of the psycopg2 library.

  1. Download the PostgreSQL source code and extract into a directory.
  2. Download the psycopg2 source code and extract into a directory.
  3. Go into the PostgreSQL source directory and execute the following commands:
  • ./configure --prefix {path_to_postgresql_source} --without-readline --without-zlib
  • make
  • make install
  1. Go into the psycopg2 source directory and edit the setup.cfg file with the following:
  • pg_config={path_to_postgresql_source/bin/pg_config}
  • static_libpq=1
  1. Execute python setup.py build in the psycopg2 source directory.

After the above steps have been completed you will then have a build directory and the custom compiled psycopg2 library will be contained within it. Copy this directory into your AWS Lambda package and you will now be able to access PostgreSQL from within AWS Lambda using the psycopg2 library.

Metadata

Release files for awslambda-psycopg2 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for awslambda-psycopg2 1.0.1
File Size Uploaded
awslambda-psycopg2-1.0.1.tar.gz 34.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for awslambda-psycopg2 1.0.1
File Interpreter ABI Platform
awslambda_psycopg2-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 77.5 kB

Release files / awslambda-psycopg2-1.0.1.tar.gz

Download URL awslambda-psycopg2-1.0.1.tar.gz
Size 34.3 kB
Tags Source
SHA-256 checksum
How to use checksums
85ff66a386be26d5857a2ebebc76ee7fa2856abe917738ae750d3518d306e754
BLAKE2b-256 checksum
How to use checksums
e551d1b75e2f68274cf24093158c52aab0d0330dd89ae79bc59364cfcf8d292b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

Release files / awslambda_psycopg2-1.0.1-py3-none-any.whl

Download URL awslambda_psycopg2-1.0.1-py3-none-any.whl
Size 43.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
034bc328d2ad1425b99ec1ce2874e5843a5e1ec4a6bcbc74ee77ef2188c0abd7
BLAKE2b-256 checksum
How to use checksums
92bcfffa8c4c7823c2b0c3cc8df16385ca4f47812434a81ee5261d05fce64ae7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

Release history Release notifications | RSS feed

1.0.2

2 release files

This release

1.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page