Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
ClickHouse launches Claude-powered Agents and House Mates partner program at Open House 2026 Read more →
BunランタイムでchDBをインストールして使用する方法
curl -sL https://lib.chdb.io | bash
gcc
clang
# GitHubリポジトリからインストール bun add github:chdb-io/chdb-bun # またはローカルにクローンしてビルドする git clone https://github.com/chdb-io/chdb-bun.git cd chdb-bun bun install bun run build
import { query } from 'chdb-bun'; // 基本的なクエリ const result = query("SELECT version()", "CSV"); console.log(result); // "23.10.1.1" // 異なる出力フォーマットでのクエリ const jsonResult = query("SELECT 1 as id, 'Hello' as message", "JSON"); console.log(jsonResult); // 計算を含むクエリ const mathResult = query("SELECT 2 + 2 as sum, pi() as pi_value", "Pretty"); console.log(mathResult); // システム情報のクエリ const systemInfo = query("SELECT * FROM system.functions LIMIT 5", "CSV"); console.log(systemInfo);
import { Session } from 'chdb-bun'; // 永続ストレージでセッションを作成する const sess = new Session('./chdb-bun-tmp'); try { // データベースとテーブルを作成する sess.query(` CREATE DATABASE IF NOT EXISTS mydb; CREATE TABLE IF NOT EXISTS mydb.users ( id UInt32, name String, email String ) ENGINE = MergeTree() ORDER BY id `, "CSV"); // データを挿入する sess.query(` INSERT INTO mydb.users VALUES (1, 'Alice', 'alice@example.com'), (2, 'Bob', 'bob@example.com'), (3, 'Charlie', 'charlie@example.com') `, "CSV"); // データをクエリする const users = sess.query("SELECT * FROM mydb.users ORDER BY id", "JSON"); console.log("Users:", users); // カスタム関数を作成して使用する sess.query("CREATE FUNCTION IF NOT EXISTS hello AS () -> 'Hello chDB'", "CSV"); const greeting = sess.query("SELECT hello() as message", "Pretty"); console.log(greeting); // 集計クエリ const stats = sess.query(` SELECT COUNT(*) as total_users, MAX(id) as max_id, MIN(id) as min_id FROM mydb.users `, "JSON"); console.log("Statistics:", stats); } finally { // リソースを解放するために必ずセッションをクリーンアップする sess.cleanup(); // データベースファイルを削除する }
このページは役に立ちましたか?