I am trying to connect to sql server from databricks using pyodbc facing below issue
import pyodbc
sql_server_url='server_url'
sqlDB='db-dev'
SQL_DB_USER='user'
SQL_DB_PASS='123'
conn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER=' + sql_server_url +';DATABASE=' + sqlDB + ';UID='+SQL_DB_USER+';PWD='+SQL_DB_PASS)
Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found (0) (SQLDriverConnect)")
so I am trying to run below bash command
%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
E: This command can only be used by root. /bin/bash: line 1: /etc/apt/sources.list.d/mssql-release.list: Permission denied sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
The same code works for standard databricks version but not for unity catalog enabled for runtime version 11.3. I have a super admin access still when I try to run this command it says permission denied.
Can anyone suggest how to install these odbc drivers?


The issue might be with the improper use of
sudoin the command I tried below code, and it successfully installed for me.Sample Code:
also refer this Similar thread which addressing similar issue.