ClickHouse Driver

Python driver for ClickHouse using its native TCP protocol

SDK
PyPI
v0.2.11
1,303 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
70 /100 Good
Development Activity 48
Maintenance 48
Community 84
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
74 /100 Good
Architecture 78
Code Quality 79
Innovation 68
Learning Curve 70

clickhouse-driver is a Python client for ClickHouse that speaks the database’s native TCP protocol rather than the HTTP interface, giving faster, more efficient query execution and result streaming. It supports the full ClickHouse type system (Array, Nullable, LowCardinality, Decimal, Map, Tuple, JSON, and more), compression, TLS, and query settings.

It ships both a native client API and a DB-API 2.0 compatible interface (clickhouse_driver.dbapi), plus optional Cython-accelerated components for performance-critical paths and NumPy/Arrow integration for efficient bulk data transfer into scientific Python workflows.

What You Get

  • Native TCP protocol client (faster than the HTTP interface) with Client.execute() for queries
  • A DB-API 2.0 compatible interface (clickhouse_driver.dbapi) for use with existing SQL tooling
  • Full ClickHouse type support (Array, Nullable, LowCardinality, Decimal, Map, Tuple, JSON, IPv4/IPv6, and more)
  • Cython-accelerated read/write buffers for performance-critical serialization paths
  • NumPy and Arrow integration for efficient bulk data transfer into analytics workflows

Common Use Cases

  • Running analytical queries against ClickHouse from Python ETL or reporting scripts
  • Bulk-loading large datasets into ClickHouse tables efficiently via the native protocol
  • Integrating ClickHouse as a data source for pandas/NumPy-based data analysis pipelines
  • Using ClickHouse through SQLAlchemy or other DB-API-based tools via the dbapi interface
  • Streaming large query results block-by-block without loading everything into memory at once

Under The Hood

Architecture - The clickhouse_driver package centers on connection.py and client.py, which implement the native ClickHouse wire protocol (protocol.py), with columns/ housing per-type (de)serialization logic, streams/ handling block-by-block result iteration, and a separate dbapi/ subpackage layering PEP 249 (DB-API 2.0) semantics on top of the native client. Tech Stack - Core serialization hot paths (bufferedreader/bufferedwriter, varint) are implemented in Cython (.pyx/.c files) for performance, with optional numpy and arrow submodules for zero-copy-ish bulk data exchange, and TLS/compression support built directly into the connection layer. Code Quality - The tests/ directory contains roughly 70 test files covering type serialization, compression, TLS, DB-API behavior, and protocol edge cases, with coverage tracked via Coveralls and CI run through GitHub Actions across supported Python versions. API Design - The native Client(...).execute('SELECT ...') call pattern is minimal for simple queries, while the DB-API layer lets it slot into existing cursor.execute()-based tooling (e.g. SQLAlchemy), though users need to choose upfront between the native and DB-API surfaces depending on which ecosystem they’re integrating with.

Used by 7 apps in this directory

C++
68%
Apache 2.0

ClickHouse

Analytics · Data Engineering · Databases

50,116

Open-source column-oriented database that delivers real-time analytical queries on petabyte-scale data with millisecond latency.

View details
95
Repo Health
90
Technical
64
Dependency
Built with
C++ 68%
Python 14%
Updated 4 days ago
C++
68%
Apache 2.0

ClickHouse

Analytics · Data Engineering · Databases

50,116

Open-source column-oriented database that delivers real-time analytical queries on petabyte-scale data with millisecond latency.

View details
95
Repo Health
90
Technical
64
Dependency
Built with
C++ 68%
Python 14%
Updated 4 days ago
C#
42%
MIT

FeatBit

Developer Tools · Devops

1,907

Self-hosted, enterprise-grade feature flag platform for safe, targeted, and data-driven feature releases.

View details
90
Repo Health
78
Technical
69
Dependency
Built with
C# 42%
TypeScript 41%
Updated 4 days ago
Python
63%
BSD 3

Flagsmith

Ab Testing Experimentation · Developer Tools · Devops

6,577

Open-source feature flagging, remote config, and A/B/multivariate testing platform for web, mobile, and server-side apps — self-host or use the hosted SaaS.

View details
90
Repo Health
82
Technical
63
Dependency
Built with
Python 63%
TypeScript 31%
Updated 6 days ago
Python
64%
Other

Keep

Automation · Devops · Monitoring

12,359

The open-source AIOps and alert management platform that unifies 130+ monitoring tools into a single pane of glass with AI-powered correlation, deduplication, and workflow automation.

View details
89
Repo Health
79
Technical
66
Dependency
Built with
Python 64%
TypeScript 36%
Updated 1 weeks ago
TypeScript
83%
Apache 2.0

nao

AI Development · Analytics

1,702

Build and deploy an open-source analytics agent that understands your data warehouse and answers business questions in plain English.

View details
84
Repo Health
76
Technical
67
Dependency
Built with
TypeScript 83%
Python 17%
Updated 6 days ago
Python
55%
Other

PostHog

Ab Testing Experimentation · Analytics · Developer Tools

39,975

The all-in-one open source product platform combining analytics, session replay, feature flags, error tracking, AI observability, and a built-in data warehouse in a single self-hostable stack.

View details
92
Repo Health
80
Technical
65
Dependency
Built with
Python 55%
TypeScript 36%
Updated 4 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers