Installing and Configuring the ODBC Driver for Linux

Linux uses named data sources (DSNs) for connecting ODBC-based client applications to Snowflake. You can choose to install the ODBC driver using the TGZ file, RPM package, or DEB package provided in the Snowflake Client Repository.

In this Topic:

Prerequisites

Operating System

For a list of the operating systems supported by Snowflake clients, see Operating System Support.

Driver Manager: iODBC or unixODBC

A driver manager is required to manage communication between Snowflake and the ODBC driver. The driver supports using either iODBC or unixODBC as the driver manager.

iODBC

If iODBC is not installed on CentOS, as sudo, execute the following command:

$ yum install libiodbc

unixODBC

unixODBC provides the odbcinst and isql command line utilities used to install, configure, and test the driver. To verify whether unixODBC is installed, execute the following commands:

$ which odbcinst

$ which isql

If unixODBC is not installed:

  1. As sudo, execute the following commands:

    $ yum search unixODBC
    
    $ yum install unixODBC.x86_64
    
  2. Verify the directory where odbcinst expects the odbcinst.ini and odbc.ini files to be located:

    $ odbcinst -j
    

    The location should be /etc.

Step 1: Verify the Package Signature (RPM or DEB only) — Optional

Note

If you are installing the ODBC driver by using yum or the TGZ file, skip this step.

If you are installing the ODBC driver using the RPM or DEB package and wish to verify the package signature before installation, perform the following tasks:

1.1: Download and Import the Latest Snowflake Public Key

To download and import the key from the public keyserver:

$ gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys <GPG_KEY_ID>

For <GPG_KEY_ID>, specify one of the following key IDs:

ODBC Driver Version

GPG Key ID

2.22.1 and higher

37C7086698CB005C

2.18.2 through 2.22.0

EC218558EABB25A1

Up to 2.18.1

93DB296A69BE019A

Note

If this command fails with the following error:

gpg: keyserver receive failed: Server indicated a failure

then specify that you want to use port 80 for the keyserver:

gpg --keyserver hkp://keyserver.ubuntu.com:80  ...

1.2: Download the RPM or DEB Driver Package

Download the package from the Snowflake Client Repository. For details, see Downloading the ODBC Driver.

1.3: Verify the Signature for the RPM or DEB Driver Package

RPM Package Signature

  1. Verify the key was imported successfully:

    $ gpg --list-keys
    

    The command should display the Snowflake key.

  2. Verify the signature:

    $ rpm -K snowflake-odbc-<version>.x86_64.rpm
    

    Note

    If rpm does not have the GPG key that you imported, the command will report that the signatures are not OK and will produce a NOKEY warning:

    $ rpm -K snowflake-odbc-<version>.x86_64.rpm
    
    snowflake-odbc-<version>.x86_64.rpm: digests SIGNATURES NOT OK
    
    $ rpm -Kv snowflake-odbc-<version>.x86_64.rpm
    
    snowflake-odbc-<version>.rpm:
        Header V4 RSA/SHA1 Signature, key ID 98cb005c: NOKEY
        Header SHA1 digest: OK
        V4 RSA/SHA1 Signature, key ID 98cb005c: NOKEY
        MD5 digest: OK
    

    If this occurs, run the following commands to export the GPG key, import the key into rpm, and verify the signature again:

    $ gpg --export -a <GPG_KEY_ID> > odbc-signing-key.asc
    $ sudo rpm --import odbc-signing-key.asc
    $ rpm -K snowflake-odbc-<version>.x86_64.rpm
    

    where <GPG_KEY_ID> is the ID for the key that you installed in 1.1: Download and Import the Latest Snowflake Public Key.

DEB Package Signature

  1. Install the package signature verification tool:

    $ sudo apt-get install debsig-verify
    
  2. Import the public key to the keyring:

    $ mkdir /usr/share/debsig/keyrings/<GPG_KEY_ID>
    $ gpg --no-default-keyring --keyring /usr/share/debsig/keyrings/<GPG_KEY_ID>/debsig.gpg --import snowflakeKey.asc
    

    where <GPG_KEY_ID> is the ID for the key that you installed in 1.1: Download and Import the Latest Snowflake Public Key.

  3. Configure a policy for the key. For details, see /usr/share/doc/debsig-verify. The policy must be stored in the following directory:

    /etc/debsig/policies/<GPG_KEY_ID>
    

    where <GPG_KEY_ID> is the ID for the key that you installed in 1.1: Download and Import the Latest Snowflake Public Key.

    Store the policy in a file named policy_name.pol, where policy_name is your name for the policy. For the policy name, you can use any text string, however the string cannot contain blank spaces.

    Here is a sample policy file for a key with the ID 37C7086698CB005C:

    <?xml version="1.0"?>
    <!DOCTYPE Policy SYSTEM "http://www.debian.org/debsig/1.0/policy.dtd">
    <Policy xmlns="http://www.debian.org/debsig/1.0/">
    <Origin Name="Snowflake Computing" id="37C7086698CB005C"
    Description="Snowflake ODBC Driver DEB package"/>
    
    <Selection>
    <Required Type="origin" File="debsig.gpg" id="37C7086698CB005C"/>
    </Selection>
    
    <Verification MinOptional="0">
    <Required Type="origin" File="debsig.gpg" id="37C7086698CB005C"/>
    </Verification>
    
    </Policy>
  4. Verify the signature:

    $ sudo debsig-verify snowflake-odbc-<version>.x86_64.deb
    

Note

By default, the dpkg package signature verification tool does not check the signature when you install the package. If you want to verify the signature every time you run dpkg, remove the --no-debsig line in the /etc/dpkg/dpkg.cfg file.

1.4: Delete the Old Snowflake Public Key — Optional

Your local environment can contain multiple GPG keys; however, for security reasons, Snowflake periodically rotates the public GPG key. As a best practice, we recommend deleting the existing public key after confirming that the latest key works with the latest signed package.

To delete the key:

$ gpg --delete-key "Snowflake Computing"

Step 2: Install the ODBC Driver

Install the driver using one of the following approaches:

Using yum to Download and Install the Driver

With version 2.21.1 of the ODBC Driver (and later versions), you can use yum to download and install the driver.

To download and install the Snowflake ODBC driver for Linux using yum:

  1. Create a file named /etc/yum.repos.d/snowflake-odbc.repo, and add the following text to the file:

    [snowflake-odbc]
    name=snowflake-odbc
    baseurl=https://sfc-repo.snowflakecomputing.com/odbc/linux/<VERSION>/
    gpgkey=https://sfc-repo.snowflakecomputing.com/odbc/Snowkey-<GPG_KEY_ID>-gpg
    

    where VERSION is the version of the driver (for example, 2.24.1) and GPG_KEY_ID is one of the following key IDs:

    ODBC Driver Version

    GPG Key ID

    2.22.1 and higher

    37C7086698CB005C

    In the settings above, baseurl and gpgkey point to the Snowflake Client Repository on AWS S3. If you want to use the mirror on Azure Blob instead, change the hostname to https://sfc-repo.azure.snowflakecomputing.com/:

    [snowflake-odbc]
    name=snowflake-odbc
    baseurl=https://sfc-repo.azure.snowflakecomputing.com/odbc/linux/<VERSION>/
    gpgkey=https://sfc-repo.azure.snowflakecomputing.com/odbc/Snowkey-<GPG_KEY_ID>-gpg
    
  2. Run the following command to install the driver:

    yum install snowflake-odbc
    

Installing the TGZ File

To install the Snowflake ODBC driver for Linux using the TGZ file that you downloaded earlier.

  1. Copy the downloaded file (snowflake_linux_x8664_odbc-version.tgz) to a working directory.

  2. Unzip the file:

    $ gunzip snowflake_linux_x8664_odbc-<version>.tgz
    
  3. Extract the files from the .tar file:

    $ tar -xvf snowflake_linux_x8664_odbc-<version>.tar
    
  4. Copy the resulting snowflake_odbc folder to the directory where you want to install the driver. Make note of this directory. You’ll need the location later in the instructions.

Installing the RPM Package

Note

The RPM package requires unixODBC as the driver manager.

To install the Snowflake ODBC driver for Linux using the RPM package that you downloaded earlier, after optionally verifying the package signature, run the following command:

$ yum install snowflake-odbc-<version>.x86_64.rpm

Note

The installation directory is /usr/lib64/snowflake/odbc/. You’ll need the location later in the instructions.

Installing the DEB Package

Note

The DEB package requires unixODBC as the driver manager.

To install the Snowflake ODBC driver for Linux using the DEB package that you downloaded earlier, after optionally verifying the package signature, run the following command:

$ sudo dpkg -i snowflake-odbc-<version>.x86_64.deb

The command may fail if any required dependencies for the package manager are not installed. If that happens, install them now:

$ sudo apt-get install -f

Note

The installation directory is /usr/lib/snowflake/odbc/. You’ll need the location later in the instructions.

Step 3: Configure the Environment (TGZ Only)

Note

If you installed the ODBC driver using the RPM or DEB package file, skip this step.

If you installed using the TGZ file, configure the environment using the installed driver manager (either iODBC or unixODBC).

Configuring with iODBC

In a terminal window, change to the snowflake_odbc directory, and run the following command to install Snowflake ODBC:

$ ./iodbc_setup.sh

This script completes the following steps:

  • Adds one Snowflake connection to your system-level /etc/odbc.ini file.

  • Adds the Snowflake driver information to your system-level /etc/odbcinst.ini file.

  • Adds all certificate authority (CA) certificates required by the Snowflake ODBC driver to your system-level simba.snowflake.ini file.

By running iodbc_setup.sh, you don’t need to set any environment variables.

Alternatively, if you don’t want Snowflake to change your system configurations, add the following environment variables to your shell configuration file (e.g. .profile, .bash_profile):

  • ODBCINI = <path>/conf/odbc.ini

  • ODBCINSTINI = <path>/conf/odbcinst.ini

Where path is the location of the snowflake_odbc directory. If you have configured other ODBC drivers in your system and plan to add the Snowflake ODBC entries to your existing odbc.ini and odbcinst.ini files in the next step, then point ODBCINI and ODBCINSTINI to the location of those files.

Configuring with unixODBC

In a terminal window, change to the snowflake_odbc directory, and run the following command to install Snowflake ODBC:

$ ./unixodbc_setup.sh

This script completes the following steps:

  • Adds a Snowflake connection to your system-level /etc/odbc.ini file.

  • Adds the Snowflake driver information to your system-level /etc/odbcinst.ini file.

  • Adds all certificate authority (CA) certificates required by the Snowflake ODBC driver to your system-level simba.snowflake.ini file.

By running unixodbc_setup.sh, you don’t need to set any environment variables.

Alternatively, if you don’t want Snowflake change your system configurations, add the following environment variables to your shell configuration file, e.g. .profile, .bash_profile:

  • ODBCSYSINI = <path>/conf/

Where path is the location of the snowflake_odbc directory. If you have configured other ODBC drivers in your system and plan to add the Snowflake ODBC entries to your existing odbc.ini and odbcinst.ini files in the next step, then point ODBCSYSINI to the location of those files.

Step 4: Configure the ODBC Driver

Configuring the ODBC driver requires adding entries to the following files:

  • <path>/lib/simba.snowflake.ini

  • /etc/odbcinst.ini (or <path>/conf/odbc.ini, if you are using environment variables)

  • /etc/odbc.ini (or <path>/conf/odbcinst.ini, if you are using environment variables)

Where path is the location of the snowflake_odbc directory.

4.1: simba.snowflake.ini File (Driver Manager and Logging)

Add the following entries to the simba.snowflake.ini file:

ErrorMessagesPath=<path>/ErrorMessages/
LogPath=/tmp/
ODBCInstLib=<driver_manager_path>
CABundleFile=<path>/lib/cacert.pem
ANSIENCODING=UTF-8

Where:

  • path is the location of the snowflake_odbc directory.

  • driver_manager_path is the location of your driver manager directory:

    • iODBC: ODBCInstLib=libiodbcinst.so.2

    • unixODBC: ODBCInstLib=libodbcinst.so

    Note

    If your driver manager directory is not included in the LD_LIBRARY_PATH environment variable, specify the full path to the driver manager library here.

Verify that you have write permissions on the log path.

The ANSIENCODING parameter specifies the application’s character encoding. The default is UTF-8. The parameter is intended for use only by Snowflake; customers should not change the value.

4.2: odbcinst.ini File (Driver Registration)

Add the following entries to the odbcinst.ini file:

[ODBC Drivers]
SnowflakeDSIIDriver=Installed

[SnowflakeDSIIDriver]
APILevel=1
ConnectFunctions=YYY
Description=Snowflake DSII
Driver=/<path>/lib/libSnowflake.so
DriverODBCVer=03.52
SQLLevel=1

Where path is the location of the snowflake_odbc directory.

4.3: odbc.ini File (DSN Entries)

For each DSN, add the following entries to the odbc.ini file:

  • DSN Name and driver name (SnowflakeDSIIDriver), in the form of <dsn_name> = <driver_name>.

  • Parameters:

    • Required connection parameters, such as server.

    • Any additional, optional parameters, such as default role, database, and warehouse.

    Parameters are specified in the form of <parameter_name> = <value>. For details about the parameters that can be set for each DSN, see ODBC Configuration and Connection Parameters.

The following example illustrates an odbc.ini file that configures two data sources that use different forms of an account identifier in the server URL:

  • testodbc1 uses an account identifier that uses an account identifier that specifies the account myaccount in the organization myorganization.

  • testodbc2 uses the account locator xy12345 as the account identifier.

    Note that testodbc2 uses an account in the AWS US West (Oregon) region. If the account is in a different region or if the account uses a different cloud provider, you need to specify additional segments after the account locator.

    [ODBC Data Sources]
    testodbc1 = SnowflakeDSIIDriver
    testodbc2 = SnowflakeDSIIDriver
    
    
    [testodbc1]
    Driver      = /usr/jsmith/snowflake_odbc/lib/libSnowflake.so
    Description =
    server      = myorganization-myaccount.snowflakecomputing.com
    role        = sysadmin
    
    
    [testodbc2]
    Driver      = /usr/jsmith/snowflake_odbc/lib/libSnowflake.so
    Description =
    server      = xy12345.snowflakecomputing.com
    role        = analyst
    database    = sales
    warehouse   = analysis
    

Note the following:

  • Both testodbc1 and testodbc2 have default roles.

  • testodbc2 also has a default database and warehouse.

Step 5: Test the ODBC Driver

Test the driver using the installed driver manager (either iODBC or unixODBC).

Testing with iODBC

Test the DSNs you created. On the command line, specify the DSN name, user login name, and password, using the following format:

iodbctest "DSN=<dsn_name>;UID=<user_name>;PWD=<password>"

For example:

$ iodbctest "DSN=testodbc2;UID=mary;PWD=password"
iODBC Demonstration program
This program shows an interactive SQL processor
Driver Manager: 03.52.0709.0909
Driver: 2.12.70 (Snowflake)

SQL>

Testing with unixODBC

Test the DSNs you created using the isql command line utility provided with unixODBC.

On the command line, specify the DSN name, user login name, and password.

For example:

$ isql -v testodbc2 mary <password>

Dec 14 22:57:50 INFO  2022078208 Driver::LogVersions: SDK Version: 09.04.09.1013
Dec 14 22:57:50 INFO  2022078208 Driver::LogVersions: DSII Version: 2.12.36
Dec 14 22:57:50 INFO  2022078208 SFConnection::connect: Tracing level: 4

+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL>