Skip to content

Documents basic configuration needed to connect to a Vertica DB using Rust

Notifications You must be signed in to change notification settings

aar021/vertica_rust_connection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

vertica_rust_connection

Documents basic configuration needed to connect to a Vertica DB using Rust

Reference

Connecting Vertica to ODBC

Tested on

This was tested in the Rust dev container of Visual Studio Code

$ cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

Getting the driver

Vertica Driver Download

sudo wget https://www.vertica.com/client_drivers/12.0.x/12.0.4-0/vertica-client-12.0.4-0.x86_64.tar.gz

Installing the driver

The final location of the driver is /opt/vertica. The version you get depends on your Vertica release.

sudo tar zxvf /path/to/vertica-client-12.0.4-0.x86_64.tar.gz -C /

After the extraction:

├── opt
│   └── vertica

Required packages

sudo apt-get update
sudo apt-get install unixodbc unixodbc-dev

Configuration

You need to configure

/etc/vertica.ini

[Driver]
DriverManagerEncoding=UTF-16
ODBCInstLib=/usr/lib/x86_64-linux-gnu/libodbcinst.so.2
ErrorMessagesPath=/opt/vertica/lib64
LogLevel=4
LogPath=/tmp

/etc/odbc.ini

[ODBC Data Sources]
Dev1Vertica="nBA database on Vertica Dev1"

[Dev1Vertica]
Description=Vertica Database
Driver=/opt/vertica/lib64/libverticaodbc.so
Database=defaultdb
Server=1.1.1.1
UID=ro_user
PWD=password
Port=5433

/etc/odbcinst.ini

[Vertica]
Description=Vertica ODBC Driver
Driver=/opt/vertica/lib64/libverticaodbc.so
UsageCount=1
[ODBC]
Threading=1 
Trace=Yes
TraceFile=/opt/vertica/odbc_trace.log

Environment Variables

Load them in your shell rc file:

export LD_LIBRARY_PATH=/opt/vertica/lib64:$LD_LIBRARY_PATH
export PATH=/opt/vertica/bin:$PATH
export VERTICAINI=/etc/vertica.ini
export ODBCSYSINI=/etc
export ODBCINI=/etc/odbc.ini
export ODBCINSTINI=/etc/odbcinst.ini

For bashrc:

vi ~/.bashrc
source ~/.bashrc

Check unixODBC Configuration:

Use the odbcinst command-line tool to check the configuration:

odbcinst -j
$ odbcinst -j
unixODBC 2.3.6
DRIVERS............: /etc/
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /home/vscode/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8

This command will print the locations of the odbc.ini and odbcinst.ini files as recognized by unixODBC.

Check DSN Listing

odbcinst -q -s

Output:

$ odbcinst -q -s
[Dev1Vertica]

Check Driver Listing

odbcinst -q -d

Never got this one to work kept getting:

$ odbcinst -q -d
odbcinst: SQLGetPrivateProfileString failed with Unable to find component name.

The Crate and Code

The crate of choice:

odbc_api

Example was taken directly from the crate documentation.

About

Documents basic configuration needed to connect to a Vertica DB using Rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages