2

Getting this error after doing the install steps as listed out here:

brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
brew update
HOMEBREW_NO_ENV_FILTERING=1 ACCEPT_EULA=y brew install --no-sandbox msodbcsql17 mssql-tools

Then i run python code trying to use it:

Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found (0) (SQLDriverConnect)")
Micah
  • 10,295
  • 13
  • 66
  • 95

1 Answers1

3

Change the driver code to directly reference the dylib file location instead of {ODBC Driver 17 for SQL Server}:

cnxn = pyodbc.connect('DRIVER=/usr/local/lib/libmsodbcsql.17.dylib;SERVER='+server+';PORT=1443;DATABASE='+database+';UID='+username+';PWD='+ password)
cursor = cnxn.cursor()
Micah
  • 10,295
  • 13
  • 66
  • 95
  • Sure wish that microsoft would have added this info to their instructions that gave the brew formula! I also had to change the ownership of the /usr/local/Homebrew path before the brew instructions would work under Mojave. Thanks Micah! – Steve L Sep 17 '19 at 15:49