Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timeout parameter on connection object #302

Open
rkudulis opened this issue Mar 24, 2021 · 1 comment
Open

timeout parameter on connection object #302

rkudulis opened this issue Mar 24, 2021 · 1 comment

Comments

@rkudulis
Copy link

Is there any way to set a timeout parameter for connection object like pyodbc has.

cnxn = pyodbc.connect(connString)  
cnxn.timeout = 3

OR

cnxn = pyodbc.connect(connString, timeout = 3)
@pacman82
Copy link
Collaborator

pacman82 commented Mar 24, 2021

AFAIK turbodbc does not allow to set a connection timeout.

In case someone wants to implement it though:

You can set SQL_ATTR_CONNECTION_TIMEOUT using SQLSetConnectionAttr.

An SQLUINTEGER value corresponding to the number of seconds to wait for any request on the connection to complete before returning to the application. The driver should return SQLSTATE HYT00 (Timeout expired) anytime that it is possible to time out in a situation not associated with query execution or login.

If ValuePtr is equal to 0 (the default), there is no timeout.

See: https://docs.microsoft.com/en-us/sql/odbc/reference/syntax/sqlsetconnectattr-function?redirectedfrom=MSDN&view=sql-server-ver15

Edit: Other timeouts (just realized I do not know which timeout the pyodbc timeout refers, too):

SQL_ATTR_LOGIN_TIMEOUT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants