import pyodbc
server = 'serve'
username = 'username'
password = 'password'
driver = '{ODBC Driver 17 for SQL Server}'
schema = 'schema'
database = 'database'
cnxn = pyodbc.connect('DRIVER='+driver+';SERVER='+server+';PORT=1433;DATABASE='+database+';UID='+dbutils.secrets.get(scope = "samplesecrets", key = "sqluname")+';PWD='+ dbutils.secrets.get(scope = "samplesecrets", key = "sqlpassword"))
Error:
cnxn = pyodbc.connect('DRIVER='+driver+';SERVER='+server+';PORT=1433;DATABASE='+database+';UID='+dbutils.secrets.get(scope = "samplesecrets", key = "sqluname")+';PWD='+ dbutils.secrets.get(scope = "samplesecrets", key = "sqlpassword"))
Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found (0) (SQLDriverConnect)")
What I tried:
%sh
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get -q -y install msodbcsql17
Error:
Reading package lists...
Building dependency tree...
Reading state information...
msodbcsql17 is already the newest version (17.8.1.1-1).
0 upgraded, 0 newly installed, 0 to remove and 81 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up msodbcsql17 (17.8.1.1-1) ...
dpkg: error processing package msodbcsql17 (--configure):
installed msodbcsql17 package post-installation script subprocess returned error exit status 127
Errors were encountered while processing:
msodbcsql17
E: Sub-process /usr/bin/dpkg returned an error code (1)
The runtime version of databricks is 13.3
Pls help me how to erase this error. Thanks
Most probably you will need to upgrade ubuntu package version to 22.04: curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
To check package version to use run: %sh cat /etc/*release