Cant find pyodbc driver despite install
10,159
I was having same issue. The only workaround I found was to pass the driver file location to the connection request. But the connection/bandwidth is extremely slow when trying to query using pyodbc
(compared with using SQL Ops Studio).
import pyodbc
import pandas as pd
driver = '/usr/local/lib/libtdsodbc.so' # Change this to where FreeTDS installed the driver library!
conn = pyodbc.connect(
driver = driver,
TDS_Version = '7.3',
server = <tunneled server>,
port = 1433,
uid = <sql_user_id>,
pwd = <sql_password>)
crsr = conn.cursor()
table = pd.read_sql(<sql statement>, conn)
crsr.close()
conn.close()
Author by
Rilcon42
Updated on September 18, 2022Comments
-
Rilcon42 over 1 year
I have
pyodbc
installed and I am trying to connect to a server, butpyodbc
can't find the drivers. I did the following:-
Installed
pyodbc
usingpip
:pip install pyodbc
Followed the Microsoft instructions.
-
Ran a test script:
import pyodbc print(pyodbc.drivers())
which returned an empty array.
What else do I need to do? I'm running the script in a Jupyter Notebook inside an Anaconda Python install.
-
-
Raihan Shafique over 4 yearsIn my case my driver was in the following location in ubuntu18.04LTS /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.4.so.1.1 And I used the above suggestion and it worked perfectly.