zillow / ctds

Python DB-API 2.0 library for MS SQL Server
MIT License
83 stars 12 forks source link

Connection timeout should not be equivalent to query timeout #58

Closed amachanic closed 4 years ago

amachanic commented 4 years ago

Currently, if I'm understanding correctly, there is exactly one timeout parameter available, on the connect function, and it is used both as connection timeout and then later as query timeout.

This is really not ideal; I often don't want to wait a long time to connect if the server is down, but I do want to wait a long time for my query to finish once I'm connected and it's actually running.

My preference would be to never conflate these two things at all. But given backward compatibility, what I would like to see changed in ctds in the addition of a second parameter, "query_timeout", which will work specifically and separately from the "timeout" parameter. If "query_timeout" is not provided, the existing parameter will continue to perform double-duty as it currently does.

joshuahlang commented 4 years ago

There are two: login_timeout and timeout (https://zillow.github.io/ctds/ctds.html#ctds.connect). Sadly FreeTDS only supports second resolution for these parameters, but they are distinct.

amachanic commented 4 years ago

Thanks for clarifying. I was looking at the documentation here and didn't see it: https://zillow.github.io/ctds/connection.html

joshuahlang commented 4 years ago

Ahh. Yes, that is for the Connection object which is returned by ctds.connect. The only way to create a Connection object that is actually connected to the database is using ctds.connect