Appearance
Class: DuckDB
Defined in: duckdb/src/duckdb.ts:33
DuckDB WASM library, a in-process SQL OLAP Database Management System..
See DuckDB for more details.
ts
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();
Properties
db
db:
AsyncDuckDB
Defined in: duckdb/src/duckdb.ts:35
Methods
load()
static
load():Promise
<DuckDB
>
Defined in: duckdb/src/duckdb.ts:50
Compiles and instantiates the raw wasm.
INFO
In general WebAssembly compilation is disallowed on the main thread if the buffer size is larger than 4KB, hence forcing load
to be asynchronous;
Returns
Promise
<DuckDB
>
A promise to an instance of the DuckDB class.
unload()
static
unload():void
Defined in: duckdb/src/duckdb.ts:70
Unloades the compiled wasm instance.
Returns
void
version()
version():
string
Defined in: duckdb/src/duckdb.ts:78
Returns
string
The DuckDB version