denisenkom / pytds

Python DBAPI driver for MSSQL using pure Python TDS (Tabular Data Stream) protocol implementation
MIT License
192 stars 53 forks source link

Azure SQL Datawarehouse Connection Fails For TDS74 (TDS Version 7.4) on Linux #86

Closed thihara closed 6 years ago

thihara commented 6 years ago

Encounters the following error when trying to connect to Azure SQL Datawarehouse.

unknown env type: 20, skipping Traceback (most recent call last): File "/home/thihara/.local/lib/python3.6/site-packages/pytds/tls.py", line 61, in recv return self._tls_conn.recv(bufsize) File "/home/thihara/.local/lib/python3.6/site-packages/OpenSSL/SSL.py", line 1783, in recv self._raise_ssl_error(self._ssl, result) File "/home/thihara/.local/lib/python3.6/site-packages/OpenSSL/SSL.py", line 1614, in _raise_ssl_error raise WantReadError() OpenSSL.SSL.WantReadError The unknown env type: 20, skipping seems to be getting thrown from process_env_chg method in tds.py.

Unfortunately my knowledge of the TDS Protocol is non-existent, so I have no idea what might be causing this.

Switching TDS version to TDS 7.3 however resolves the issue.

connect(... tds_version=tds_base.TDS73 ...)

It's worth noting that I have used ctds (depends on FreeTDS) before and had to switch the TDS version to 7.3 as well.

This happens on Debian and Ubuntu.

My Dev machine is on MacOS and it works without an issue. Note that however in the case of ctds and FreeTDS had TDS version set to 7.3 upon installation via homebrew.

However I don't really think that's what's affecting pytds since this is a pure python implementation.

denisenkom commented 6 years ago

I don't think the "unknown env type: 20" is causing this problem. Can you provide full stack trace?

denisenkom commented 6 years ago

Also please change log level to DEBUG and send me logs. Don't post them here, they may contain sensitive information.

denisenkom commented 6 years ago

Try latest version from master branch. It implements routing feature of TDS 7.4 protocol. I think lack of this feature was causing disconnection in your case.