chDB-go provides Go bindings for chDB, enabling you to run ClickHouse queries directly in your Go applications with zero external dependencies.
Installation
Step 1: Install libchdb
First, install the chDB library:
Step 2: Install chdb-go
Install the Go package:
Or add it to your go.mod:
Usage
Command line interface
chDB-go includes a CLI for quick queries:
Go Library - quick start
Stateless queries
For simple, one-off queries:
Stateful queries with session
For complex queries with persistent state:
SQL driver interface
chDB-go implements Go’s database/sql interface:
Query streaming for large datasets
For processing large datasets that don’t fit in memory, use streaming queries:
Benefits of query streaming:
- Memory efficient - Process large datasets without loading everything into memory
- Real-time processing - Start processing data as soon as first chunk arrives
- Cancellation support - Can cancel long-running queries with
Cancel()
- Error handling - Check for errors during streaming with
Error()
API documentation
chDB-go provides both high-level and low-level APIs:
System requirements
- Go 1.21 or later
- Compatible with Linux, macOS
Last modified on June 23, 2026