Skip to main content

Requirements

  • Python 3.8+
  • Supported platforms: macOS and Linux (x86_64 and ARM64)

Installation

Usage

Command line interface

Run SQL queries directly from the command line:

Basic python usage

Connection-based API (recommended)

For better resource management and performance:

Data input methods

File-based data sources

chDB supports 70+ data formats for direct file querying:

Output format examples

DataFrame operations

Legacy DataFrame API

Stateful sessions

Sessions maintain query state across multiple operations, enabling complex workflows:

Advanced session features

See also: test_stateful.py.

Python DB-API 2.0 interface

Standard database interface for compatibility with existing Python applications:

User defined functions (UDF)

Extend SQL with custom Python functions:

Basic UDF usage

Advanced UDF with custom return types

UDF best practices

  1. Stateless Functions: UDFs should be pure functions without side effects
  2. Import Inside Functions: All required modules must be imported within the UDF
  3. String Input/Output: All UDF parameters are strings (TabSeparated format)
  4. Error Handling: Include try-catch blocks for robust UDFs
  5. Performance: UDFs are called for each row, so optimize for performance

Streaming query processing

Process large datasets with constant memory usage:

Python table engine

Query Pandas DataFrames

Custom data sources with PyReader

Implement custom data readers for specialized data sources:

Performance and optimization

Benchmarks

chDB consistently outperforms other embedded engines:
  • DataFrame operations: 2-5x faster than traditional DataFrame libraries for analytical queries
  • Parquet processing: Competitive with leading columnar engines
  • Memory efficiency: Lower memory footprint than alternatives
More benchmark result details

Performance tips

GitHub repository

Last modified on June 23, 2026