I\'ve been stuck trying to connect to an SQL Server using AWS Lambda functions for a long while now.
To do so i\'m trying to use any library (tried with pyodbc, pyp
yum install gcc gcc-c++
wget ftp://ftp.unixodbc.org/pub/unixODBC/unixODBC-2.3.5.tar.gz
tar xvzf unixODBC-2.3.5.tar.gz
cd unixODBC-2.3.5
configure it with the correct sysconfdir value
./configure --sysconfdir=/var/task --disable-gui --disable-drivers --enable-iconv --with-iconv-char-enc=UTF8 --with-iconv-ucode-enc=UTF16LE --prefix=/home
make install
[ODBC Driver 13 for SQL Server]
Description=Microsoft ODBC Driver 13 for SQL Server
Driver=/var/task/msodbcsql/msodbcsql/lib64/libmsodbcsql-13.1.so.9.1
UsageCount=1
On your computer, in the same root directory create file odbc.ini
[ODBC Driver 13 for SQL Server]
Driver = ODBC Driver 13 for SQL Server
Description = My ODBC Driver 13 for SQL Server
Trace = No
on your python program use pyodbc:
import pyodbc
def lambda_handler(event, context):
server = "xxxxxxxxxxxxxxxxxxxx"
database = "xxxxxxxxxxxxxxxxxxxx"
username = "xxxxxxxxxxxxxxxxxxxx"
password = "xxxxxxxxxxxxxxxxxxxx"
cnxn = pyodbc.connect('DRIVER={ODBC Driver 13 for SQL Server};SERVER='+server+';DATABASE='+database+';UID='+username+';PWD='+ password)
cursor = cnxn.cursor()
...other things....
and now play the game !