pypyodbc icon indicating copy to clipboard operation
pypyodbc copied to clipboard

pypyodbc.connection_timeout dont work

Open fetidbell opened this issue 5 years ago • 0 comments

import pypyodbc
pypyodbc.connection_timeout = 10

serverName = 'server'
database = 'DB'
username = 'user'
password = 'pass'

try:
    conn = pypyodbc.connect('DRIVER={ODBC Driver 13 for SQL Server};SERVER='+serverName+';DATABASE='+database+';UID='+username+';PWD='+password)
except pypyodbc.Error as ex:
    print(ex, serverName, database)

Hi everyone!

I'm trying to connect to Microsoft SQLServer 2012 with timeout, but it doesn't work: pypyodbc.connect lasts for 36 seconds (not 10 as i want) and then i get exception

('08001', '[08001] [Microsoft][ODBC Driver 13 for SQL Server]Named Pipes Provider: Could not open a connection to SQL Server [53]. ')

I can't understand why's that. I've tried to set timeout in connection string like that, but it doesn't work too:

conn = pypyodbc.connect('DRIVER={ODBC Driver 13 for SQL Server};SERVER='+serverName+';DATABASE='+database+';UID='+username+';PWD='+password+';Connection Timeout=10')

fetidbell avatar Apr 23 '19 10:04 fetidbell