I am trying to connect to my SQL server on google colab by using pyodbc. However, it tells me that I cannot find the driver.
Code to install packages (I replaced IP, port and password with x)
``` !sudo apt-get install unixodbc-dev
!pip install pyodbc
!pip install chart_studio ```
``` import pyodbc
conn = pyodbc.connect(DRIVER = '{ODBC Driver 17 for SQL Server}',
SERVER = 'xxx.xxx.x.xx, xxxx',
DATABASE = 'Database',
UID = 'sa',
PWD = 'xxxxxx')
cursor = conn.cursor()
```
I get this error:
```---------------------------------------------------------------------------
Error Traceback (most recent call last)
<ipython-input-12-3e54dc10e278> in <module>()
3 DATABASE = 'Database_PIL',
4 UID = 'sa',
----> 5 PWD = 'mbdxwko2')
6
7 cursor = conn.cursor()
Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found (0) (SQLDriverConnect)")
```
Do you have any suggestion how to make it work?
Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…