akshayp
akshayp

Reputation: 119

Use MSSQL with AWS Lambda

I am trying to connect to MSSQL database from AWS Lambda (using python) and really struggling to proceed further.

I tried many options with pyodbc, pypyodbc, pymssql they work on local development machine (Windows 7), however AWS Lambda is unable to find the required packages when deployed on AWS. I use ZAPPA for deployment of Lambda package.

I searched through many forums but unable to see the anything moving ahead, any help on this would be highly appreciated.

Many thanks, Akshay

Upvotes: 5

Views: 3817

Answers (2)

marcin2x4
marcin2x4

Reputation: 1429

Try to do import cython together with pymssql in your code.

Upvotes: 1

akshayp
akshayp

Reputation: 119

I 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

Below is the folder structure of my lambda deployment package

pymssql-lambda-aws-python

Let me know if you further need help with this.

Upvotes: 1

Related Questions