Skip to main content

Crate chdb_rust

Crate chdb_rust 

Source
Expand description

§chdb-rust

Rust FFI bindings for chDB, an embedded ClickHouse database.

§Overview

This crate provides a safe Rust interface to chDB, allowing you to execute ClickHouse SQL queries either statelessly (in-memory) or with persistent storage using sessions.

§Quick Start

use chdb_rust::execute;
use chdb_rust::arg::Arg;
use chdb_rust::format::OutputFormat;

// Execute a simple query
let result = execute("SELECT 1 + 1 AS sum", None)?;
println!("Result: {}", result.data_utf8_lossy());

§Features

  • Stateless queries: Execute one-off queries without persistent storage
  • Stateful sessions: Create databases and tables with persistent storage
  • Multiple output formats: JSON, CSV, TabSeparated, and more
  • Thread-safe: Connections and results can be safely sent between threads

§Examples

See the examples directory for more detailed examples.

§Safety

This crate uses unsafe code to interface with the C library, but provides a safe Rust API. All public functions are safe to call, and the crate ensures proper resource cleanup.

Modules§

arg
Query argument definitions for chDB.
connection
Connection management for chDB.
error
Error types for chdb-rust.
format
Input and output format definitions for chDB queries.
log_level
Log level definitions for chDB.
query_result
Query result handling for chDB.
session
Session management for persistent chDB databases.

Functions§

execute
Execute a one-off query using an in-memory connection.