Using psycopg2 with Lambda to Update Redshift (Python)

前端 未结 7 1699
情深已故
情深已故 2020-11-27 19:36

I am attempting to update Redshift from a Lambda function using python. To do this, I am attempting to combine 2 code fragments. Both fragments are functional when I run the

7条回答
  •  有刺的猬
    2020-11-27 19:42

    In order for this to work you need to build psycopg2 with statically linked libpq.so library. Check out this repo https://github.com/jkehler/awslambda-psycopg2. It has already build psycopg2 package and instructions how to build it yourself.

    Back to your questions:

    What is causing this problem?

    psycopg2 needs to be build an compiled with statically linked libraries for Linux.

    Does it matter that Lambda uses Python 2.7 when I use 3.4?

    Yes it does, lambda only supports 2.7 version. Just create virtual environment and install all necessary packages in there.

    Does it matter that I zipped the contents of my file on a Windows machine?

    As long as all the libraries you zipped could ran on Linux it doesn't

    Has anyone been able to successfully connect to Redshift from lambda?

    yes.

提交回复
热议问题