Skip to content

Instantly share code, notes, and snippets.

@iangow
Created February 24, 2025 18:56
Show Gist options
  • Save iangow/abefa19887956c1cec4c79dd17ce1296 to your computer and use it in GitHub Desktop.
Save iangow/abefa19887956c1cec4c79dd17ce1296 to your computer and use it in GitHub Desktop.
Setting up the ODBC driver on MacOS.

Setting up the ODBC driver on MacOS

The following instructions improve on those here by avoiding the need to:

a. Compile the Homebrew binary itself b. Set the path for the Homebrew binary

Steps

  1. Install HomeBrew using the .pkg file available here.
  2. Get the mssql-release files by running the following command in Terminal:
/opt/homebrew/bin/brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
  1. Install the driver by running the following command in Terminal:
HOMEBREW_ACCEPT_EULA=Y /opt/homebrew/bin/brew install msodbcsql18 mssql-tools18
  1. Install the R package odbc by running install.packages("odbc") at the R console in RStudio.
  2. Access the database:
library(DBI)
db <- dbConnect(odbc::odbc(),
                Driver = "/opt/homebrew/lib/libmsodbcsql.18.dylib",
                Server = "xxx.database.windows.net",
                Database = "database",
                UID = "user",
                PWD = "password")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment