Documentation Index
Fetch the complete documentation index at: https://private-7c7dfe99-page-updates.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
clickhouse-cpp is the official C++ client library for ClickHouse, providing a fast and type-safe
interface to ClickHouse using its native binary protocol.
Build instructions, usage examples, and additional documentation are available in the project’s
GitHub repository: https://github.com/ClickHouse/clickhouse-cpp.
The library is under active development. While it already supports core ClickHouse functionality,
some features and data types may not yet be fully implemented or supported.Your feedback is highly valuable and helps guide the prioritization of new features and
improvements. If you encounter limitations, missing functionality, or unexpected behavior, please
share your observations or feature requests through the issue tracker at
https://github.com/ClickHouse/clickhouse-cpp/issues
Including the library into your project
The simplest way to incorporate the library into your project is using CMake’sFetchContent
module. This approach lets you pin an exact library version and build it as part of your normal
CMake workflow.
WITH_OPENSSL option enables TLS support in the library and is required when connecting to
ClickHouse Cloud or other SSL-enabled ClickHouse deployments. While it can be omitted for non-TLS
connections, enabling it is generally recommended.
Building with SSL support requires the OpenSSL development packages to be installed. Install
libssl-dev on Debian, Ubuntu or their derivatives; openssl-devel for Fedora, Red Hat; or
openssl on macOS, using homebrew.
After the dependency is made available, link your target against the exported library target:
Examples
Setting the client object
Create aClient instance to establish a connection to ClickHouse. The following example
demonstrates connecting to a local ClickHouse instance, where no password is required and SSL isn’t
enabled.
Creating tables and running queries without data
To execute a query that doesn’t return any data, such as creating tables, use theExecute method.
The same approach applies to other statements like ALTER TABLE, DROP, etc..
Inserting Data
To insert data into a table, construct aBlock and populate it with column objects matching the
table schema. Data is appended column-by-column and then inserted in a single operation using the
Insert method, which is optimized for efficient batch writes.
Selecting the data
To execute a query that returns data, use theSelect method and provide a callback to process the
result. Query results are delivered as Block objects, reflecting ClickHouse’s native
column-oriented data representation.
Supported Data Types
UInt8,UInt16,UInt32,UInt64,Int8,Int16,Int32,Int64UInt128,Int128Decimal32,Decimal64,Decimal128Float32,Float64DateDateTime,DateTime64DateTime([timezone]),DateTime64(N, [timezone])UUIDEnum8,Enum16StringFixedString(N)LowCardinality(String)andLowCardinality(FixedString(N))Nullable(T)Array(T)TupleMapIPv4,IPv6Point,Ring,Polygon,MultiPolygon
