Tip
If you already have a ClickHouse instance running, skip the steps to set up and clean up ClickHouse.
-
Start a ClickHouse instance:
docker run -d --rm --name some-clickhouse-server -p 8123:8123 -e CLICKHOUSE_USER=user -e CLICKHOUSE_PASSWORD=pass clickhouse/clickhouse-server
-
Install the ClickHouse ADBC driver:
dbc install --level user clickhouse
-
Customize the C++ program
main.cpp- Change the connection arguments in the
AdbcDatabaseSetOption()calls- Format
uriaccording to the ClickHouse HTTP interface, or keep it as is
- Format
- If you changed which database you're connecting to, also change the SQL SELECT statement in
AdbcStatementSetSqlQuery()
- Change the connection arguments in the
-
Build and run the C++ program:
Using Make:
pixi run make ./clickhouse_demo
Or using CMake:
pixi run cmake -B build pixi run cmake --build build ./build/clickhouse_demo
-
Stop the Docker container running ClickHouse:
docker stop some-clickhouse-server
-
Clean build artifacts:
Using Make:
pixi run make clean
Using CMake:
rm -rf build