Objective: Connect to a MS SQL Server in AWS Lambda
Error From AWS Lambda:
START RequestId: 37951004-404b-11e7-98fd-5177b3a46ec6 Version: $LATEST
module initialization error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 13 for SQL Server' : file not found (0) (SQLDriverConnect)")
END RequestId: 37951004-404b-11e7-98fd-5177b3a46ec6
My Approach:
refering to Tesseract OCR on AWS Lambda via virtualenv
- Installed unixODBC and ODBC Driver 13 for SQL Server in an aws ec2 instance
- Created a deployment package (i.e.
pip install -t pyodbc /home/ec2-user/lambda
and copied the relevant files to zip root) mkdir lib
and copied all shared libraries by looking upldd pyodbc.so
*ldd libmsodbcsql-13.0.so.1.0
- change
LD_LIBRARY_PATH
tolib
in lambda.py and upload the zip to Lambda
Zip File Structure:
.
+-- lambda.py
+-- pyodbc.so
+-- pyodbc-4.0.16-py2.7.egg-info
+-- lib
| +-- libodbc*.so etc.
My Guess:
From the response it looks like everything is running OK except for the unixODBC manager cannot find the driver on AWS Lambda Instance
Question:
How do I bundle the driver with my package for AWS Lambda to use? Or Is there a way to tell ODBC driver manager to look for libmsodbcsql-13.0.so.1.0
?
I have tried offline installation of unixODBC and set ./configure --prefix=/home/ec2-user/lambda --libdir=..
and manually changing odbcinst.ini
but no hope.
(sorry I am not so familiar with anything outside python environment so I am not sure about all the shared libraries stuff and couldn't solve my problem by just googling for a few days)