0

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.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Srinivas
  • 1
  • 1
  • So after you installed OpenSSL did you reinstall pymssql from source? – Gord Thompson Feb 15 '18 at 18:52
  • Yes, I followed the steps mentioned in earlier thread. First uninstalled (python -m pip uninstall pymssql) the pymssql than reinstalled from source(python -m pip install --no-binary pymssql pymssql). Not sure how to check, it installed updated version with new build on SSL. – Srinivas Feb 15 '18 at 23:37
  • when connecting using pymssql still it's defaulting the TDS version to 7.1 as earlier, not taking from freeTDS.conf file(TDS 7.3). When I used TSQL it is taking the TDS Version from freeTDS.conf file. – Srinivas Feb 15 '18 at 23:45
  • After uninstalling the 'pymssql' and reinstalling using the below option got the below message. #/opt/anaconda3/bin/python -m pip install --no-binary pymssql pymssql Collecting pymssql Using cached pymssql-2.1.3.tar.gz Skipping bdist_wheel for pymssql, due to binaries being disabled for it. Installing collected packages: pymssql Running setup.py install for pymssql ... done Successfully installed pymssql-2.1.3 – Srinivas Feb 20 '18 at 15:19
  • @Srinivas have you solve this ? – Nilesh May 31 '19 at 22:08

0 Answers0