Trying to connect to an Azure SQL DB (v12) using pymssql, I am able to connect query and write to my local MSSQL instance using pymssql.
I am getting an "Adaptive Server connection failed" failed error and my research seems to point to FreeTDS, but I have not installed FreeTDS on my machine.
Using the tsql utility, i am able to connect to the Azure SQL instance
Why would I fail to connect using pymssql?
pymssql connection string
import pymssql
conn = pymssql.connect(server='<severname>.database.windows.net',user='mickey@in4live', password='<pass>', database='tesdb')
cursor = conn.cursor()
cursor.execute("select 1")
Outputs
conn = pymssql.connect(server='.database.windows.net',user='mickey@', database='tesdb') 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 (:1433)\n'
However
tsql -H <servername>.database.windows.net -p 1433 -U mickey@<servername> -P <pass>
Connects successfully
pip install pymssql
(except for pymssql version 2.1.2, which turned out to be an anomaly) are statically linked to FreeTDS and therefore include the required FreeTDS components as an integral part of the pymssql install. (I believe that they are compiled into "_mssql.pyd".) – Gord Thompson