Objective: Connect to a MS SQL Server in 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
refering to Tesseract OCR on AWS Lambda via virtualenv
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 up ldd pyodbc.so
* ldd libmsodbcsql-13.0.so.1.0
LD_LIBRARY_PATH
to lib
in lambda.py and upload the zip to Lambda.
+-- lambda.py
+-- pyodbc.so
+-- pyodbc-4.0.16-py2.7.egg-info
+-- lib
| +-- libodbc*.so etc.
From the response it looks like everything is running OK except for the unixODBC manager cannot find the driver on AWS Lambda Instance
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)
UnixODBC consists of a lot of libraries, installed in /usr/local/lib, and a few executable files (binaries) installed into /usr/local/bin.
The unixODBC driver manager is an open source ODBC driver manager that can be used with the Db2® ODBC driver on all supported Linux® and UNIX operating systems.
Is there a way to tell ODBC driver manager to look for
libmsodbcsql-13.0.so.1.0
?
You can run odbcinst -j
and check where the driver ini file is located (odbcinst.ini
) so you can set the path there. Otherwise create the new one at ~/.odbcinst.ini
which can define the path to SQL ODBC driver library.
Example INI config file:
[ODBC Driver 13 for SQL Server]
Description=Microsoft ODBC Driver 13 for SQL Server
Driver=/path/to/libmsodbcsql-13.0.so.1.0
Here is the example command to create the config file (~/.odbcinst.ini
):
printf "[ODBC Driver 13 for SQL Server]\nDescription=Microsoft ODBC Driver 13 for SQL Server\nDriver=/path/to/libmsodbcsql-13.0.so.1.0\n" >> ~/.odbcinst.ini
If the driver file exists, but still you got file not found, run: conda update libgcc
.
See: PyODBC : can't open the driver even if it exists.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With