Problems using MySQL with AWS Lambda in Python

后端 未结 9 1102
南方客
南方客 2020-12-05 17:43

I am trying to get up and running with AWS Lambda Python (beginner in Python btw) but having some problems with including MySQL dependency. I am trying to follow the instruc

9条回答
  •  温柔的废话
    2020-12-05 18:33

    Using lambda-docker you can set up and test your Lambda functions without access to a like-wise Linux environment.

    To set up your lambda, use a lambda-docker build image to run a detached docker container and run pip install commands on the container. Then export the container, grab the installed packages under usr/lib, and place them in your AWS Lambda package.

    Then you can test for compatibility by running your lambda on a lambda-docker image. If it works, go forth and upload to AWS Lambda with confidence.

    docker run -d -v "$PWD":/var/task lambci/lambda:build-python2.7 tail -f /dev/null 
    
    docker ps
    
    docker exec 0c55aae443e6 pip install pandas
    
    docker exec 0c55aae443e6 pip install sqlalchemy
    
    docker exec 0c55aae443e6 pip freeze
    
    docker exec 0c55aae443e6 python -c "import site; print(site.getsitepackages())"
    
    docker container export -o lambda_ready_container 0c55aae443e6
    

提交回复
热议问题