0

When trying to connect to the server/database I'm getting this error:

[Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'SQL Server' : file not found (0) (SQLDriverConnect)")]

In the company where I work, Python runs on a Unix computer that we connect to. The database server I'm trying to connect to is a Microsoft SQL Server RDBMS.

My end goal is to manipulate the data using Python in Jupyter notebook.

This is the code I'm using:

import pyodbc

cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=localhost;DATABASE=testdb;UID=me;PWD=pass')
Mihai Chelaru
  • 7,614
  • 14
  • 45
  • 51
Touka113
  • 1
  • 2
  • Possible duplicate of [Connecting to Microsoft SQL server using Python](https://stackoverflow.com/questions/33725862/connecting-to-microsoft-sql-server-using-python) – EJoshuaS - Stand with Ukraine May 28 '19 at 16:32
  • It sounds like you simply haven't installed an ODBC Driver for SQL Server. Check the list returned by `pyodbc.drivers()` to see what drivers are available to your Python app. – Gord Thompson May 28 '19 at 17:37
  • @GordThompson I assume the ODBS Driver for SQL Server should be installed on the Linux computer that Python runs on and not on my personal computer, correct? This is what pyodbc.drivers() returned: 'AmazonRedshift', 'Hive', 'Impala', 'Oracle', 'PostgreSQL', 'Salesforce', 'SQLServer', 'Teradata' – Touka113 May 28 '19 at 19:25
  • **(1)** Yes, the ODBC driver needs to be installed on the machine that will be running the Python code. **(2)** Based on the `pyodbc.drivers()` list, try `DRIVER=SQLServer` and see if that works. – Gord Thompson May 28 '19 at 21:51

0 Answers0