pyodbc.OperationalError: ('08001', '[08001] [Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: Error code 0x2746 (10054) (SQLDriverConnect)')
See original GitHub issueEnvironment Hi, I am running the following –
- Python: 3.6 (64 bit)
- pyodbc: 4.0.27
- OS: Linux (Redhat 7.6)
- driver: ODBC Driver 17 for SQL Server
and am trying to access a SQL SERVER (version 10.0.1600.22) hosted on a Windows NT 5.2 (XP/Server 2003) machine.
Code
`def connectToSQLServer(server_name, username, password, db_name):
conn = pyodbc.connect(
'Driver={ODBC Driver 17 for SQL Server};'
f'Server={server_name};'
f'Database={db_name};'
f'UID={username};'
`f'PWD={password};'`
'Mars_Connection=Yes;'
)
return conn
conn = connectToSQLServer(server_name=‘<server_name>’, username=‘<username>’,password=<password>,db_name=‘<db_name>’)`
Issue
Issue I am receiving the following error –
‘Driver={ODBC Driver 17 for SQL Server};’ pyodbc.OperationalError: (‘08001’, ‘[08001] [Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: Error code 0x2746 (10054) (SQLDriverConnect)’)
I am able to access several other SQL Server machines using the same environment and code without issue, although they are using more recent Operating Systems (Windows NT 6.0+) and SQL Server versions (10.5+).
I understand that Windows NT 5.2 and SQL Server (10.0.1600.22) are very old and no longer supported. I read the following ticket (https://github.com/Microsoft/msphpsql/issues/252) and some people suggested the Operating System needs to be upgraded. So I’m wondering if that may be the case here.
However, I am a little skeptical because I am able to establish connection when I run the same code but from my local Windows 10 laptop, which uses the Windows equivalent of the same ODBC driver. My local Windows 10 machine also uses the same Python and pyodbc versions. So my real question is, how come I can establish a connection from my Windows 10 machine but not from the Linux machine? Could there be something else at play here?
Thanks a lot for your help.
Issue Analytics
- State:
- Created 4 years ago
- Comments:49 (12 by maintainers)
Top Related StackOverflow Question
Hi, I was experiencing the same problem, and fixed thanks to @v-chojas comment above. Just edited /etc/ssl/openssl.cnf and changed:
In case anyone (like me) stumbles onto this thread without knowing even the basics of linux; this is how I ended up implementing @roirodriguez’s fix in my Dockerfile:
sed -ireplaces text in a file in-place, while thechmod-command was necessary to give the current user access rights to the file.