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.

Install and setup

pip install aws-psycopg2

Source code : https://github.com/AbhimanyuHK/aws-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.

Release files for aws-psycopg2 1.3.8

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

Source distribution (sdist)

Source distribution for aws-psycopg2 1.3.8
File Size Uploaded
aws-psycopg2-1.3.8.tar.gz 34.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aws-psycopg2 1.3.8
File Interpreter ABI Platform
aws_psycopg2-1.3.8-py3-none-any.whl Python 3 none any Details

Total release size: 73.8 MB

Release files / aws-psycopg2-1.3.8.tar.gz

Download URL aws-psycopg2-1.3.8.tar.gz
Size 34.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f847bd1cb57830a6b4e3576d79cc67a528ea65aa77a4c7728f9c64dfbb14f91f
BLAKE2b-256 checksum
How to use checksums
7c99e044d6056240fdc08d58d3b682975f321c562440dac8fa941fd74835aab5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / aws_psycopg2-1.3.8-py3-none-any.whl

Download URL aws_psycopg2-1.3.8-py3-none-any.whl
Size 73.8 MB
Tags Python 3
SHA-256 checksum
How to use checksums
be3e186479c1ef1ff21ecf6f8e8260f96fb9380ceac3bfb084ccbc089bdeaa09
BLAKE2b-256 checksum
How to use checksums
1c41ba9c525bead49252cf96fb8c80161b9f45b6db858ab36aecbd1375144b73
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release history Release notifications | RSS feed

This release

1.3.8 This release

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

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