2023-04-14

Psycopg 3 AWS Lambda layer - missing libpq/static linking

Has anyone succeeded in building a psycopg3 AWS lambda layer?

I'm using psycopg version 3.1.8 in my python code, and I get this error when testing the AWS lambda function:

{
  "errorMessage": "Unable to import module 'lambda_function': no pq wrapper available.\nAttempts made:\n- couldn't import psycopg 'c' implementation: No module named 'psycopg_c'\n- couldn't import psycopg 'binary' implementation: cannot import name 'pq' from 'psycopg_binary' (/var/task/psycopg_binary/__init__.py)\n- couldn't import psycopg 'python' implementation: libpq library not found",
  "errorType": "Runtime.ImportModuleError",
  "requestId": "839c4ea4-a313-42ab-b439-4bbde7830268",
  "stackTrace": []
}

I've tried to look it up, there are many implementations on psycopg2 layers, that have been statically linked with the required libpq library.

I've tried to do as explained here but only with psycopg3: https://github.com/jkehler/awslambda-psycopg2

And even here - trying to create a libpq layer: https://github.com/DrLuke/postgres-libpq-aws-lambda-layer

but to no success (I can't seem to obtain a compiled libpq.so file)

Thanks for any help!



No comments:

Post a Comment