在 Bun 中安装 chDB
要求
安装 libchdb
curl -sL https://lib.chdb.io | bash
安装
参见:chdb-bun
GitHub 仓库
您可以在 chdb-io/chdb-bun 找到该项目的 GitHub 仓库。
用法
Query(query, *format) (临时)
import { query } from 'chdb-bun';
// Query (ephemeral)
var result = query("SELECT version()", "CSV");
console.log(result); // 23.10.1.1
Session.Query(query, *format)
import { Session } from 'chdb-bun';
const sess = new Session('./chdb-bun-tmp');
// Query Session (persistent)
sess.query("CREATE FUNCTION IF NOT EXISTS hello AS () -> 'Hello chDB'", "CSV");
var result = sess.query("SELECT hello()", "CSV");
console.log(result);
// Before cleanup, you can find the database files in `./chdb-bun-tmp`
sess.cleanup(); // cleanup session, this will delete the database