@hpcc-js/wasm-duckdb
TypeScript icon, indicating that this package has built-in type declarations

1.6.0 • Public • Published

@hpcc-js/wasm-duckdb

This package rewraps the DuckDB webassembly distribution provided by DuckDB, this is purly a convenience to provide a consistent loading experience with the rest of the @hpcc-js.wasm library. See DuckDB and DuckDB-wasm for more details.

Installation

npm install @hpcc-js/wasm-duckdb

Usage

import { DuckDB } from "@hpcc-js/wasm-duckdb";

let duckdb = await DuckDB.load();
const c = await duckdb.db.connect();

const data = [
    { "col1": 1, "col2": "foo" },
    { "col1": 2, "col2": "bar" },
];
await duckdb.db.registerFileText("rows.json", JSON.stringify(data));
await c.insertJSONFromPath('rows.json', { name: 'rows' });

const arrowResult = await c.query("SELECT * FROM read_json_auto('rows.json')");
const result = arrowResult.toArray().map((row) => row.toJSON());
expect(result.length).to.equal(data.length);
for (let i = 0; i < result.length; i++) {
    expect(result[i].col2).to.equal(data[i].col2);
}

c.close();

Reference

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i @hpcc-js/wasm-duckdb

    Weekly Downloads

    7

    Version

    1.6.0

    License

    Apache-2.0

    Unpacked Size

    8.52 MB

    Total Files

    10

    Last publish

    Collaborators

    • hpcc-js