1.0.4 • Published 2 years ago

chdb-bun v1.0.4

Weekly downloads
-
License
Apache2.0
Repository
-
Last release
2 years ago

chDB-bun

chdb-bun

Experimental chDB FFI bindings for bun.sh

Status

  • experimental, unstable, subject to changes
  • requires libchdb on the system
  • requires gcc

Build binding

bun install chdb-bun

Usage

Query Constructor

import { db } from 'chdb-bun';

const conn = new db('CSV')
console.log(conn.query("SELECT version()"));

Query (query, *format)

import { db } from 'chdb-bun';
const conn = new db('CSV')

// Query (ephemeral)
var result = conn.query("SELECT version()", "CSV");
console.log(result) // 23.10.1.1

Session (query, format, path)

import { db } from 'chdb-bun';
const conn = new db('CSV', '/tmp')

// Query Session (persistent)
conn.session("CREATE FUNCTION IF NOT EXISTS hello AS () -> 'chDB'");
result = conn.session("SELECT hello()", "CSV");
console.log(result)

⚠️ Sessions persist table data to disk. You can specify path to implement auto-cleanup strategies:

const temperment = require("temperment");
const tmp = temperment.directory();
conn.session("CREATE FUNCTION IF NOT EXISTS hello AS () -> 'chDB'", "CSV", tmp)
var result =  = chdb.Session("SELECT hello();")
console.log(result) // chDB
tmp.cleanup.sync();
1.0.4

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago