0

I am getting quite confused on how to approach connecting to SQL server from a Python Lambda function. At this point, I am just trying to connect to my SQL Server (Azure) instance from the recommended AMI image .

The first and most popular approach seems to be using pymssql. Within that, it seems like you can go with the precompiled FreeTDS version (export PYMSSQL_BUILD_WITH_BUNDLED_FREETDS=1) or you can install FreeTDS on your system.

I have tried both and always ended up with the following error:

>>> pymssql.connect('myserver.database.windows.net', 'myuser@myserver.database.windows.net', 'mypass', 'mydb')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pymssql.pyx", line 641, in pymssql.connect (pymssql.c:10824)
pymssql.OperationalError: (20002, 'DB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (myserver.database.windows.net:1433)\n')  

Note, that if I install FreeTDS on the system and attempt to connect with tsql, I have no problems at all.

I can provide more info on exactly how my installs are setup if someone can help me with this approach. Alternatively, I am happy to go the pyodbc route but would need some help in that direction, too.

Update:

I tried going the pyodbc route and managed to get the drivers installed following this guide. Will update on future progress

Fonnae
  • 453
  • 1
  • 4
  • 12
  • Not really helpful to your current position - Ive had success using pyodbc. Why do you need\want to use it as a lamda function though? – addohm Aug 02 '18 at 01:20
  • @Jaberwocky I want to update the database when a new file arrives in S3. S3 has the capability to call a Lambda function when a new file arrives. – Fonnae Aug 02 '18 at 03:11

0 Answers0