There are multiple ways to connect Snowflake to RStudio using MacOs. The two main ways are using the iODBC Driver or the unixODBC manager. Using the unixODBC manager is recommended because although the iODBC manager is simpler to use, it doesn't work in many cases. This tutorial focuses on using the unixODBC manager to connect to Snowflake.
Open the terminal and enter the following commands to install the manager.
brew update
brew install unixodbc freetds
The ODBC Manager is a useful tool to configure the ODBC DSN. Once downloaded, open the file and follow the instructions to install the driver.
{width=100%}
The iODBC Manager will still need to be installed, despite what was mentioned earlier. It contains files needed to properly configure DSNs.
Download the latest version of the driver from the Snowflake Client Repository. Download the version that uses the AWS endpoint.
{width=100%}
{width=100%}
{width=100%}
{width=100%}
{width=100%}
Follow the prompts to install the driver.
In the terminal, use the following command to open the simba.snowflake.ini file:
vi /opt/snowflake/snowflakeodbc/lib/universal/simba.snowflake.ini
In the file, there are instructions to uncomment the ODBCInstLib being used with the driver manager. The driver manager being used is iODBC. Locate the "Darwin Specific ODBCInstLib" in the file, then uncomment the line of code that contains "libodbcinst.dylib".
{width=100%}
:wq
to save the file. If this throws an error, use :wq!
.`odbcinst -j`
{width=50%}
Open the odbcinst.ini file
sudo vi /usr/local/etc/odbcinst.ini
If prompted for a password, enter your computer's password to access the file.
| [ODBC Drivers]
| SnowflakeDSIIDriver=Installed
| [SnowflakeDSIIDriver]
| APILevel=1
| ConnectFunctions=YYY
| Description=Snowflake DSII
| Driver=/opt/snowflake/snowflakeodbc/lib/universal/libSnowflake.dylib
| DriverODBCVer=03.52
| SQLLevel=1
| The end result will look like the following image.
{width=75%}
:wq
Open the local odbc.ini file
sudo vi /usr/local/etc/odbc.ini
Add the sample entry to the file.
| [ODBC Data Sources]
| SNOWFLAKE_ODBC = SnowflakeDSIIDriver
| [SNOWFLAKE_ODBC]
| Driver = /opt/snowflake/snowflakeodbc/lib/universal/libSnowflake.dylib
| Description = Internal Snowflake
| uid = \<>
| server = \<>.snowflakecomputing.com
| database = \<>
| schema = \<>
| warehouse = \<>
| role = \<>
| tracing = 6
Edit the sample entry to match your snowflake database. In the simplest form, this will include the driver (location of the driver), a name(in this case it's 'SNOWFLAKE_ODBC'), and the server (the url for your database). The other options will be the default parameters if nothing is specified in the ODBC connect string.
Save and quit using :wq
odbcinst -q -s
The output should list your ODBC DSN
Run the following command, replacing each prompt with your Snowflake DSN's parameters.
isql -v <SNOFLAKE_ODBC_DSN_NAME> <USERNAME> <PASSWORD>
The result will look similar to the following image:
{width=50%}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.