Installing and configuring the ODBC Driver 4.x for Linux¶
Version: 4.x. Switch to ODBC 3.x · Choose another task.
Linux uses named data sources (DSNs) for connecting ODBC-based client applications to Snowflake. You can choose to install the ODBC driver using the .tar.gz archive, RPM package, or DEB package.
Important
These instructions install ODBC 4.x. Installing 4.x replaces 3.x on the machine. If you currently use 3.x, read the migration guide and validate on a separate host first. To stay on 3.x, use the 3.x Linux instructions.
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:
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:
If unixODBC is not installed:
- As
sudo, execute the following commands:
-
Verify the directory where
odbcinstexpects theodbcinst.iniandodbc.inifiles to be located:Use the file locations reported by this command in the configuration steps below.
Step 1: Verify the package signature (RPM or DEB only) — Optional¶
Note
If you are installing the ODBC driver by using yum or the
.tar.gz archive, 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¶
For ODBC 4.x, download and import the Snowflake GPG public key:
$ gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 3C98F63C9292CE02Note
If this command fails with the following error:
then specify that you want to use port 80 for the keyserver:
For an older installer, see historical signing keys.
1.2: Download the RPM or DEB driver package¶
Download the package from the Snowflake Client Repository. For details, see Downloading the ODBC Driver 4.x.
1.3: Verify the signature for the RPM or DEB driver package¶
RPM package signature¶
-
Verify the key was imported successfully:
The command should display the Snowflake key.
-
Verify the signature:
Note
If
rpmdoes not have the GPG key that you imported, the command will report that the signatures are not OK and will produce aNOKEYwarning:If this occurs, run the following commands to export the GPG key, import the key into
rpm, and verify the signature again: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¶
-
Install the package signature verification tool:
-
Import the public key to the keyring:
where
<GPG_KEY_ID>is the ID for the key that you installed in 1.1: Download and import the latest Snowflake public key. -
Configure a policy for the key. For details, see
/usr/share/doc/debsig-verify. The policy must be stored in the following directory: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, wherepolicy_nameis 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 3C98F63C9292CE02:
<?xml version="1.0"?> <!DOCTYPE Policy SYSTEM "http://www.debian.org/debsig/1.0/policy.dtd"> <Policy xmlns="https://www.debian.org/debsig/1.0/"> <Origin Name="Snowflake Computing" id="3C98F63C9292CE02" Description="Snowflake ODBC Driver DEB package"/> <Selection> <Required Type="origin" File="debsig.gpg" id="3C98F63C9292CE02"/> </Selection> <Verification MinOptional="0"> <Required Type="origin" File="debsig.gpg" id="3C98F63C9292CE02"/> </Verification> </Policy> -
Verify the signature:
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:
Step 2: Install the ODBC Driver¶
Install the driver using one of the following approaches:
- Use yum to download and install the driver.
- Install the driver by using the downloaded
.tar.gzarchive. - Install the downloaded RPM package.
- Install the downloaded DEB package.
Using yum to download and install the driver¶
You can use yum to download and install the driver.
To download and install the Snowflake ODBC driver for Linux using yum:
-
Create a file named
/etc/yum.repos.d/snowflake-odbc.repo, and add the following text to the file:Set
VERSION_NUMBERto the 4.x version to install, for example 4.0.0. SetGPG_KEY_IDto 3C98F63C9292CE02. For aarch64, useodbc/linuxaarch64/<VERSION_NUMBER>/inbaseurl.To use the Azure mirror, replace
sfc-repo.snowflakecomputing.comwithsfc-repo.azure.snowflakecomputing.comin both URLs. See Downloading Snowflake Clients, Connectors, Drivers, and Libraries. -
Run the following command to install the driver:
Installing the tar.gz archive¶
Download the .tar.gz package for your architecture from Downloading the ODBC Driver 4.x.
Extract snowflake-odbc-<version>.<arch>.tar.gz into a working directory. For example, for x86_64:
The archive contains usr/lib64/snowflake/odbc/, with lib, include, and templates subdirectories.
Move the extracted driver directory to your chosen installation location and use its absolute path when
registering lib/libsfodbc.so. The archive does not run an installer or include the 3.x setup scripts.
Register the driver and configure a DSN as described in Step 3: Configure the ODBC Driver.
On aarch64 hosts, extract snowflake-odbc-<version>.aarch64.tar.gz instead.
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:
On aarch64 hosts, install
snowflake-odbc-<version>.aarch64.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. Make sure that the unixodbc and odbcinst packages are installed before attempting to install the DEB package.
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:
On aarch64 hosts, install snowflake-odbc-<version>.aarch64.deb.
If the SF_ACCOUNT variable is unset, the dpkg command shows a warning. When you set the variable as shown, a Snowflake connection is added to the odbc.ini file.
The command might fail if any required dependencies for the package manager are not installed. If that happens, install them now:
Note
The installation directory is /usr/lib64/snowflake/odbc/. You’ll need the location later in the instructions.
Step 3: Configure the ODBC Driver¶
Configuring the ODBC driver requires adding entries to the following files:
- For 4.x logging and driver-manager encoding, a user-level
sf.odbc.ini, as described below. - Your driver manager’s
odbcinst.inifile for driver registration. - Your driver manager’s
odbc.inifile for DSNs.
For RPM and DEB installations, the installer registers the 4.x driver with unixODBC. For a 4.x archive,
<path> in the registration example below is the absolute path to the extracted driver directory containing
lib/libsfodbc.so.
3.1: Driver configuration and logging¶
For 4.x, create ~/.snowflake/sf.odbc.ini for logging or encoding settings, or set SF_ODBC_INI to the
absolute path of your configuration file. The Linux driver does not search its installation directory for
this file. Set file permissions to 0600. For example:
Use UTF-16 for unixODBC and UTF-32 for iODBC when SQLWCHAR is four bytes. See
Configuration differences for the complete search order and
recognized keys. Connection settings belong in the DSN or connection string, not in this logging file.
Verify that you have write permissions on the log path.
3.2: odbcinst.ini file (driver registration)¶
Add the following entries to the odbcinst.ini file:
Replace <path> with the absolute installation directory containing lib/libsfodbc.so.
3.3: odbc.ini file (DSN entries)¶
For each DSN, add the following entries to the odbc.ini file:
-
DSN Name and driver name (Snowflake ODBC), in the form of
<dsn_name> = <driver_name>. -
Parameters:
- Required connection parameters, such as
server. - Any additional, optional parameters, such as default
role,database, andwarehouse.
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. - Required connection parameters, such as
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:
-
testodbc1uses the account name as an identifier for the accountmyaccountin the organizationmyorganization. -
testodbc2uses the account locatorxy12345as the account identifier.Note that
testodbc2uses 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.
Note the following:
- Both
testodbc1andtestodbc2have default roles. testodbc2also has a default database and warehouse.
Step 4: 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:
After connecting, confirm that the client reports a 4.x driver version.
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:
After connecting, confirm that the client reports a 4.x driver version.