Skip to content
ODBC driver for ClickHouse
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cmake Only set OPENSSL_ROOT_DIR if not defined (#150) Jan 10, 2019
contrib
debian
driver
test LowCardinality temporary fix #157 (#158) Feb 13, 2019
vs
.appveyor.yml
.clang-format Unicode linux & macos mode (#96) Aug 3, 2018
.gitattributes
.gitignore
.gitmodules
.travis.yml
CMakeLists.txt Better Travis (#130) Oct 18, 2018
LICENSE
MACOS.md
README.md Ssl options (#148) Dec 27, 2018
format_sources Convert time functions (#54) Jan 26, 2018
release_macos.sh

README.md

Build Status

If you are macos user see MACOS.md

Cloning a Project with Submodules

Please note - git submodules are used in this project.

When you clone such a project, by default you get the directories that contain submodules, but none of the files within them. So, in order to build the project, you need either:

  • clone repo with all submodules altogether (use --recursive)
git clone --recursive https://github.com/yandex/clickhouse-odbc
  • or add submodules manually after main project cloned - in the root of source tree run:
git submodule update --init --recursive

Installing Prerequisites (Linux)

You'll need to have installed:

  • Fresh C compiler, which understands -std=c++14
  • Static libraries
    • static libgcc
    • static libstdc++
    • static libodbc
  • cmake >= 3

DEB-based Linux

Install unixodbc-dev >= 2.3.0 or libiodbc2-dev

sudo apt install unixodbc-dev

or

sudo apt install libiodbc2-dev

RPM-based Linux

CentOS is shipped with gcc 4.X, which is not suitable for this task. Fedora and CentOS do not have static libodbc provided, so you'll need either to build your own, or download 3-rd party packages. Static libodbc is available for Fedora 25 and Fedora 26. If you are running another OS, you can try to build your own RPMs from this project.

Building (Linux)

  1. At the root of source directory:
mkdir -p build; cd build && cmake .. && make -j $(nproc || sysctl -n hw.ncpu || echo 4)

Please use cmake3 to build the project on CentOS 7. You can install it with yum install cmake3.

  1. libclickhouseodbc.so will be at build/driver/libclickhouseodbc.so
mkdir -p build; cd build && cmake .. && make -j $(nproc || sysctl -n hw.ncpu || echo 4)

Building (Linux Debian based .deb package)

sudo apt install -y devscripts debhelper cmake ninja-build lsb-release unixodbc-dev
debuild -us -uc -i --source-option=--format="3.0 (native)"

or

sudo apt install -y sudo pbuilder fakeroot debhelper debian-archive-keyring debian-keyring
sudo pbuilder create --configfile debian/.pbuilderrc && pdebuild --configfile debian/.pbuilderrc

Building (windows visual studio)

cd vs && build_vs.bat

Building (windows cmake) (Developer only: setup window still not working)

cd vs && build_cmake.bat

Build with tests (needs configured ~/.odbc.ini with DSN=clickhouse_localhost)

( cd ../contrib && git clone https://github.com/nanodbc/nanodbc )
cmake -G Ninja -DTEST_DSN=clickhouse_localhost -DCMAKE_BUILD_TYPE=Debug -DUSE_DEBUG_17=1 .. && ninja
ctest -V```


## ODBC configuration

edit ~/.odbc.ini :

```(ini)
[ClickHouse]
Driver = $(PATH_OF_CLICKHOUSE_ODBC_SO)
# Optional settings:
#Description = ClickHouse driver
# New all-in one way to specify connection with [optional] settings:
#url = https://default:password@localhost:8443/query?database=default&max_result_bytes=4000000&buffer_size=3000000
# Minimal (will connect to port 8443 if https:// or 8123 if http:// ):
url = https://localhost

# Old way:
#server = localhost
#password = 123456
#database = default
#uid = default
#port = 8123

# sslmode variants: allow - ignore self-signed and bad certificates; require - check certificates (and fail connection if something wrong)
#sslmode = require
#privatekeyfile =
#certificatefile =
#calocation =

#trace=1
#tracefile=/tmp/chlickhouse-odbc.log

Sometimes you should change ~/.odbcinst.ini or /etc/odbcinst.ini or /Library/ODBC/odbcinst.ini :

[Clickhouse]
Driver=$(PATH_OF_CLICKHOUSE_ODBC_SO)

Testing

Run isql -v ClickHouse

Also look test/ contents

You can’t perform that action at this time.