Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

Connecting JavaScript and DuckDB Quack Server with ADBC

Instructions

Tip

If you already have a DuckDB Quack server instance running, skip the steps to set up DuckDB.

Prerequisites

  1. Install Node.js (version 22 or later)

    • Alternatively, you can use Bun or Deno
  2. Install dbc

  3. Install DuckDB

Set up DuckDB server

  1. Start the DuckDB CLI:

    duckdb
  2. Create a table:

    CREATE TABLE penguins AS FROM read_csv('https://blobs.duckdb.org/data/penguins.csv', nullstr = 'NA');
  3. Start a server from the DuckDB session:

    CALL quack_serve('quack:localhost');

    Note the auth_token value that DuckDB prints.

Connect to DuckDB via Quack protocol

  1. Install the Quack ADBC driver:

    dbc install --pre quack
  2. Install dependencies:

    npm --prefix .. install
  3. Customize the script main.js as needed

    • Change the uri connection argument
      • Replace YOUR_AUTH_TOKEN with the auth_token printed by DuckDB
      • Change the host and port if applicable
    • If you changed which database you're connecting to, also change the SQL SELECT statement in conn.query()
  4. Run the script:

    Node.js:

    node main.js

    Bun:

    bun run main.js

    Deno:

    deno run --allow-ffi --allow-env main.js

Clean up

If you started a DuckDB server, exit the DuckDB CLI:

.exit