DuckDB Async NodeJS Wrappers

1.4.2 · deprecated · verified Tue Apr 21

duckdb-async provides Promise-based and TypeScript-first wrappers for the DuckDB NodeJS API, allowing developers to interact with DuckDB databases using modern `async/await` patterns instead of traditional callbacks. Currently at version 1.4.2, its releases have historically aligned with the `duckdb-node` module, which it depends on. A key differentiator is its comprehensive TypeScript support and the conversion of most callback-driven methods in `duckdb-node`'s `Database`, `Connection`, and `Statement` classes into promise-returning equivalents. Notably, the `Database` constructor is replaced by a static `Database.create()` factory method to accommodate async initialization. However, it's critical to note that `duckdb-async` is currently in a deprecated state; the maintainers have announced that it, along with `duckdb-node`, will not be released for DuckDB 1.5.x (~Early 2026) and subsequent versions. Users are advised to migrate to the newer `@duckdb/node-api` package for ongoing support and future compatibility.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates connecting to an in-memory DuckDB database, executing a simple query, performing DDL/DML, and closing the connection using async/await.

import { Database } from "duckdb-async";

async function simpleTest() {
  const db = await Database.create(":memory:");
  // Example of using a query with parameters
  const rows = await db.all("select * from range(?,?)", 1, 10);
  console.log('Query Result:', rows);

  // Example of a run operation (e.g., DDL or DML without returning rows)
  await db.run("CREATE TABLE items (id INTEGER, name VARCHAR)");
  await db.run("INSERT INTO items VALUES (?, ?)", 1, 'Apple');
  await db.run("INSERT INTO items VALUES (?, ?)", 2, 'Banana');

  const allItems = await db.all("SELECT * FROM items");
  console.log('All Items:', allItems);

  // Close the database connection (important for file-based databases)
  await db.close();
}

simpleTest().catch(console.error);

view raw JSON →