How to configure pymssql with SSL support on Ubuntu?

后端 未结 3 1907
礼貌的吻别
礼貌的吻别 2020-11-28 14:05

What were the steps required to configure (the now discontinued) pymssql with SSL support on Ubuntu so I can connect to a SQL Server instance that requires an encrypted con

3条回答
  •  情话喂你
    2020-11-28 14:41

    For Ubuntu 16.04 it seems that at least the Docker containers have a FreeTDS version that already supports SSL.

    Also, at least for Python 2.7, Cython is not needed:

    https://github.com/tds-fdw/ci-setup/blob/master/ubuntu16.04/Dockerfile (lines 23-39)

    But there's something to keep in mind!

    The TDS version to connect to Azure must be forced to be at least 7.1 (or newer, depending on your needs: https://www.freetds.org/userguide/choosingtdsprotocol.htm)

    Otherwise you will see the infamous:

    [ERROR] (20017, 'DB-Lib error message 20017, severity 9:\nUnexpected EOF from the server\nNet-Lib error during Operation now in progress (115)\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection failed\n')

    For some reason this was not needed for Ubuntu 14.04 and pymssql 2.1.3 without any extra configuration (https://github.com/tds-fdw/ci-setup/blob/master/ubuntu14.04/Dockerfile)

    It can be done with either:

    export TDSVER=7.1
    

    Or, at the Python code, and at the connect function, adding the parameter:

     tds_version='7.1'
    

    With that, I am able to to use pymssql 2.1.4 to connect to Azure without issues.

提交回复
热议问题