1
votes

How do we create a pymssql package for lambda. I tried creating it using pip install pymssql -t . When I run my lambda function it complaints saying that Unable to import module 'lambda_function': No module named lambda_function

I follow the steps on this link http://docs.aws.amazon.com/lambda/latest/dg/lambda-python-how-to-create-deployment-package.html

I have a windows machine

2
pymssql relies on freetds. You'll have to build freetds on an AMI and include that in your zip. Follow this link to get an idea of how to do that. - somtingwong

2 Answers

2
votes

Glad that it worked for you, could you please share the working process for your, me too tried different trial and error steps and ended up with the following one which is working fine in AWS Lambda, I am using PYMSSQL package only.

1) did 'pip install pymssql' on amazon EC2 instance as under the hood Amazon uses Linux AMIs to run their Lambda functions.

2) copied the generated .so files and packaged inside the Lambda deployment package hope this will helps others as well who are searching for the solution.

Hope this will help you further, can you please share what you did to connect to MSSQL server using AWS Lambda.

Below is the folder structure of my lambda deployment package

pymssql-lambda-aws-python

0
votes

Finally i could do it. It didnt worked with windows packages so used ubuntu to package freetds.so file and it worked.