Using psycopg2 with Lambda to Update Redshift (Python)

前端 未结 7 1731
情深已故
情深已故 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:39

    oh boy! while some of the answers may be really great and working! Just stumbled upon this https://pypi.org/project/aws-psycopg2/ and it worked like a charm for me. steps :

    mkdir aws-psycopg2

    cd aws-psycopg2

    vi get_layer_packages.sh

    export PKG_DIR="python"
    
    rm -rf ${PKG_DIR} && mkdir -p ${PKG_DIR}
    
    docker run --rm -v $(pwd):/foo -w /foo lambci/lambda:build-python3.6 \
        pip install -r requirements.txt --no-deps -t ${PKG_DIR}
    

    vi requirements.txt

    aws-psycopg2
    

    then do : chmod +x get_layer_packages.sh

    ./get_layer_packages.sh

    zip -r aws-psycopg2.zip .

    upload this zip to the AWS Lambda Layer!

提交回复
热议问题