Ducklings API Documentation
    Preparing search index...

    A connection to a DuckDB database (async API for Cloudflare Workers).

    All query methods in this class are async and return Promises.

    Index

    Data Insertion

    • Insert data from an Arrow IPC stream buffer into a table.

      Creates a new table with the given name from the Arrow IPC data. If the table already exists, the call is a no-op (uses CREATE TABLE IF NOT EXISTS).

      Important: The IPC stream must not contain dictionary-encoded columns. Flechette's tableFromArrays() defaults to dictionary(utf8()) for string columns. Use explicit utf8() types to avoid this:

      Parameters

      • tableName: string

        The name of the table to create

      • ipcBuffer: Uint8Array

        Arrow IPC stream bytes (use tableToIPC(table, { format: 'stream' }))

      Returns Promise<void>

      DuckDBError If the connection is closed or the IPC data is invalid

      import { tableFromArrays, tableToIPC, utf8 } from '@ducklings/workers';

      const table = tableFromArrays(
      { id: [1, 2, 3], name: ['Alice', 'Bob', 'Charlie'] },
      { types: { name: utf8() } } // Required for string columns
      );
      const ipcBuffer = tableToIPC(table, { format: 'stream' });
      await conn.insertArrowFromIPCStream('users', ipcBuffer);

    Other

    • Executes a SQL statement without returning results.

      Parameters

      • sql: string

        The SQL statement to execute

      Returns Promise<number>

      Promise resolving to number of rows affected

    • Executes a SQL query and returns the results. This is async to support httpfs in Cloudflare Workers.

      Type Parameters

      • T = Record<string, unknown>

      Parameters

      • sql: string

        The SQL query to execute

      Returns Promise<T[]>

      Promise resolving to array of result rows as objects

    • Executes a SQL query and returns results as an Arrow table.

      Parameters

      • sql: string

        The SQL query to execute

      Returns Promise<Table<TypeMap>>

      Promise resolving to Arrow Table