I am able to connect to Azure SQL Server using T-SQL like below.
tsql -H testdb.database.windows.net -p 1433 -U testuser -P testpass -D testdb
I am not able to connect when I use pymssql.
>>import pymssql
>>connection = pymssql.connect(server='testdb', user='testuser@testdb', password='testpass', database='testdb')
This fails with an error:
Unexpected error:
Traceback (most recent call last):
File "pymssql.pyx", line 635, in pymssql.connect (pymssql.c:10734)
File "_mssql.pyx", line 1902, in _mssql.connect (_mssql.c:21821)
File "_mssql.pyx", line 637, in _mssql.MSSQLConnection.init (_mssql.c:6581)
File "_mssql.pyx", line 1630, in _mssql.maybe_raise_MSSQLDatabaseException (_mssql.c:17524)
_mssql.MSSQLDatabaseException: (20002, b'DB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (testdb:1433)\n')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./testdb_Azure_Test.py", line 13, in
connection = pymssql.connect(server='testdb', user='testuser@testdb', password='testpass', database='testdb')
File "pymssql.pyx", line 641, in pymssql.connect (pymssql.c:10824)
pymssql.OperationalError: (20002, b'DB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (testdb:1433)\n')
After checking the same type of problem here. I followed all the mentioned steps and installed the SSL from openssl.org site because centOS doesn't have the SSL bundled with it.
I installed the SSL(OpenSSL 1.0.1e-fips 11 Feb 2013) from openssl.org and freeTDS version (FreeTDS 0.95.19) and using python3.5.
When I check with tsql -C it showed OpenSSL= YES and TDS Version 7.3.
Compile-time settings (established with the "configure" script)
Version: freetds v0.95
freetds.conf directory: /usr/local/etc
MS db-lib source compatibility: no
Sybase binary compatibility: no
Thread safety: yes
iconv library: yes
TDS version: 7.3
iODBC: no
unixodbc: no
SSPI "trusted" logins: no
Kerberos: no
OpenSSL: yes
GnuTLS: no
I still phasing the same problem, Not sure what I am doing wrong. Is the version I used for SSL is old one do I need to install any new version.
I know it is working for most of the after installing the SSL, Please advise I am struggling with this issue for long time. Please advise what I am missing and what steps and versions I need to follow to make Azure to work.
I appreciate your help in advance.