title: ODBC Sql Server 17 driver on Mac OS X
body: <p>In order to execute this <code>python</code> code [that works on Ubuntu 18] on a MAC, </p>
  
  <pre><code>import pyodbc as odbc
  
  sql_conn_irs = odbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER=xxx.xxx.xxx.xxx;DATABASE=irs;UID=xxxxx;PWD=xxxxxxxx;')
  </code></pre>
  
  <p>I installed <code>SQL Server Driver</code> like this:</p>
  
  <pre><code>mm2:~ ivan$ HOMEBREW_NO_ENV_FILTERING=1 ACCEPT_EULA=Y brew install msodbcsql17 mssql-tools
  ==&gt; Installing msodbcsql17 from microsoft/mssql-release
  ==&gt; Installing dependencies for microsoft/mssql-release/msodbcsql17: unixodbc
  ==&gt; Installing microsoft/mssql-release/msodbcsql17 dependency: unixodbc
  ==&gt; Downloading https://homebrew.bintray.com/bottles/unixodbc-2.3.7.mojave.bottle.1.tar.gz
  ==&gt; Downloading from https://akamai.bintray.com/d9/d9f30688c0639d73b9e3a4b4b94d3679b2762e2cf0bff6b2ad64fcd175cc30ca?__gda__=exp=1581885422~hmac=2d3
  ######################################################################## 100.0%
  ==&gt; Pouring unixodbc-2.3.7.mojave.bottle.1.tar.gz
    /usr/local/Cellar/unixodbc/2.3.7: 46 files, 1.8MB
  ==&gt; Installing microsoft/mssql-release/msodbcsql17
  ==&gt; Downloading https://download.microsoft.com/download/1/9/A/19AF548A-6DD3-4B48-88DC-724E9ABCEB9A/msodbcsql-17.5.1.1.tar.gz
  ######################################################################## 100.0%
  ==&gt; odbcinst -u -d -n "ODBC Driver 17 for SQL Server"
  ==&gt; odbcinst -i -d -f ./odbcinst.ini
  ==&gt; Caveats
  If you installed this formula with the registration option (default), you'll
  need to manually remove [ODBC Driver 17 for SQL Server] section from
  odbcinst.ini after the formula is uninstalled. This can be done by executing
  the following command:
      odbcinst -u -d -n "ODBC Driver 17 for SQL Server"
  ==&gt; Summary
    /usr/local/Cellar/msodbcsql17/17.5.1.1: 9 files, 2MB, built in 37 seconds
  ==&gt; Installing mssql-tools from microsoft/mssql-release
  ==&gt; Downloading https://download.microsoft.com/download/F/D/1/FD16AA69-F27D-440E-A15A-6C521A1972E6/mssql-tools-17.5.1.2.tar.gz
  ######################################################################## 100.0%
    /usr/local/Cellar/mssql-tools/17.5.1.2: 11 files, 869KB, built in 7 seconds
  ==&gt; Caveats
  ==&gt; msodbcsql17
  If you installed this formula with the registration option (default), you'll
  need to manually remove [ODBC Driver 17 for SQL Server] section from
  odbcinst.ini after the formula is uninstalled. This can be done by executing
  the following command:
      odbcinst -u -d -n "ODBC Driver 17 for SQL Server"
  </code></pre>
  
  <p>I then executed this to see what it returns:</p>
  
  <pre><code>mm2:~ ivan$ odbcinst -j
  unixODBC 2.3.4
  DRIVERS............: /etc/odbcinst.ini
  SYSTEM DATA SOURCES: /etc/odbc.ini
  FILE DATA SOURCES..: /etc/ODBCDataSources
  USER DATA SOURCES..: /Users/ivan/.odbc.ini
  SQLULEN Size.......: 8
  SQLLEN Size........: 8
  SQLSETPOSIROW Size.: 8
  </code></pre>
  
  <p>Yet when I cat that file,</p>
  
  <pre><code>mm2:~ ivan$ more /etc/odbcinst.ini
  /etc/odbcinst.ini: No such file or directory
  mm2:~ ivan$
  </code></pre>
  
  <p>When I run the <code>python</code> code, I get:</p>
  
  <pre><code>---------------------------------------------------------------------------
  Error                                     Traceback (most recent call last)
  &lt;ipython-input-8-d2b1c4f70099&gt; in &lt;module&gt;()
  
  ---&gt; 11 sql_conn_irs = odbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER=xxx.xxx.xxx.xxx;DATABASE=irs;UID=xxxx;PWD=xxxxx;')
       12 query = "SELECT * FROM Table_Curve order by Date asc"
       13 dfirs = pd.read_sql(query, sql_conn_irs)
  
  Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found (0) (SQLDriverConnect)")
  </code></pre>
  
  <p>Is there extra magic in installing SQL Server drivers on a Mac OS X?</p>