Skip to content

Connectors ​

Database connectors issue query requests to a backing data source.

A connector instance should expose a query(query) method that returns a Promise. The query argument is an object with the following properties:

  • sql: The SQL query to evaluate.
  • type: The query format type, either "exec" (no return value) or "arrow". This property is required; servers reject a request without it.
  • Any additional connector-specific options.

For the "arrow" type, a connector returns the raw Arrow IPC bytes as an ArrowIPCBytes value, which is an ArrayBuffer, a Uint8Array, or an array of Uint8Array chunks; the coordinator decodes them to an Arrow table.

Once instantiated, register a connector with the coordinator using the coordinator.databaseConnector() method.

decodeIPC ​

decodeIPC(data, options)

Decode Arrow IPC bytes to an Arrow table. The data argument is an ArrowIPCBytes value. The optional options argument gives Arrow IPC extraction options; if unspecified, date and timestamp values are extracted as JavaScript Date objects. Use this to read query results directly from a connector, outside the coordinator.

restConnector ​

restConnector(uri)

Create a new HTTP rest connector to a DuckDB data server at the given uri (default "http://localhost:3000/").

wasmConnector ​

wasmConnector(options)

Create a new DuckDB-WASM connector with the given options. This method will instantiate a new DuckDB instance in-browser using Web Assembly. If no existing DuckDB-WASM instance is provided as an option, a new instance is created lazily upon first access.

The supported options are:

  • duckdb: An existing DuckDB-WASM instance to query. If unspecified, a new instance is created.
  • connection: An existing connection to a DuckDB-WASM instance to use. If unspecified, a new connection is created.
  • log: A Boolean flag (default false) that indicates if DuckDB-WASM logs should be written to the browser console. This option is ignored when an existing duckdb instance option is provided.