我尝试使用pyodbc连接谷歌Colab中的SQL服务器,但是提示找不到驱动程序。
安装包的代码(我用x替换了IP、端口和密码)
``` !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()
```
我收到了这个错误:
```---------------------------------------------------------------------------
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)")
```
你有任何建议如何使它工作吗?
谢谢!
CalledProcessError: Command 'b'curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -\ncurl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list\nsudo apt-get update\nsudo ACCEPT_EULA=Y apt-get -q -y install msodbcsql17\n'' returned non-zero exit status 100.
- Pravin