Skip to content

feat: Add psycopg2 for Python 3.12+ support#171

Open
jonathanbcsouza wants to merge 1 commit into
aws-samples:masterfrom
jonathanbcsouza:feature/psycopg2-rotation-lambda-python312
Open

feat: Add psycopg2 for Python 3.12+ support#171
jonathanbcsouza wants to merge 1 commit into
aws-samples:masterfrom
jonathanbcsouza:feature/psycopg2-rotation-lambda-python312

Conversation

@jonathanbcsouza
Copy link
Copy Markdown

@jonathanbcsouza jonathanbcsouza commented Mar 9, 2026

Issue #, if available:

Python 3.10 reaches AWS Lambda deprecation after June 2026 and PyGreSQL is compiled for specific Python versions. Lambda functions for python 3.12 run on Amazon Linux 2023 [1]. Solution here is to replace PyGreSQL with Psycopg [2].

Without this, users would see the following error for each respective function:

python3.12:
Runtime.ImportModuleError — No module named '_pg'

Description of changes:

  • Replacing PyGreSQL (pg/pgdb) with psycopg2-binary
  • Adding minimum code changes for the new imports
  • Attaching tested Lambda Layer. Users will need to attach thsi to their function

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant