PrivateactivePrivateconnPrivateconnectionPrivatedbPrivateinitializedPrivateinitialPrivateoptionsPrivatepoachedPrivateworkerCancels the query currently being consumed through DuckDB's pending-query API.
Whether DuckDB accepted a cancellation request
Check whether a statement can be safely wrapped as a paginated subquery. Preparing a zero-row wrapper validates the shape without scanning the result.
Closes the database connection and releases resources.
This method:
After calling this method, init must be called again before executing any queries.
A promise that resolves when cleanup is complete
Executes a SQL query and returns the results.
The SQL statement to execute
A promise that resolves to the query result containing columns, rows, row count, and duration
Executes a query while retaining at most maxRows rows.
One additional row is consumed to determine whether the result was truncated. If it was, the remaining DuckDB stream is cancelled.
PrivateexecuteOptionalmaxRows: numberPrivatefinishGets CREATE TABLE statements for all tables and views in the database.
This method queries the database catalog and generates DDL statements that describe the schema, useful for providing context to AI assistants.
A promise that resolves to a string containing all CREATE TABLE statements, or an empty string if no tables exist
Gets auto-completion suggestions for the current input.
Provides suggestions for:
The current input text
The cursor position within the text
A promise that resolves to an array of completion suggestions
Return the exact row count when a statement can be used as a subquery. A null result means the statement should use bounded, non-pageable output.
Gets a list of all tables in the database.
Queries all attached databases and returns tables with their qualified names when multiple databases are present, or just the table name when only the default 'memory' database exists.
A promise that resolves to an array of table names (qualified if multiple databases)
Gets the schema (column definitions) for a specific table.
The name of the table to get the schema for
A promise that resolves to an array of column definitions
Initializes the DuckDB database.
This method performs the following setup:
A promise that resolves when initialization is complete
Checks if the poached extension is loaded.
True if the poached extension is available
Loads the poached extension for SQL tokenization.
The poached extension provides tokenize_sql() which uses DuckDB's internal parser for accurate SQL syntax highlighting.
A promise that resolves to true if loaded successfully, false otherwise
PrivatereadRegisters a file in DuckDB's virtual filesystem.
This allows you to load external files (CSV, Parquet, JSON) into DuckDB
and query them using functions like read_csv(), read_parquet(), etc.
The virtual filename to register (e.g., 'data.csv')
The file contents as a Uint8Array
PrivatereinitializePrivatereleaseReleases a result that was not read to the end (truncated, cancelled, or failed while streaming). DuckDB-Wasm keeps such a result open on the connection and refuses to prepare statements until it is gone ("connection has an open result"), which broke pagination checks and the AI write guard after a truncated result. Cancelling does not release it; starting another query does.
Restores DuckDB configuration settings to the values present immediately after initialization.
Only settings whose normalized values changed are reset. If DuckDB refuses an in-place reset (for example because configuration was locked), callers can opt into recreating the instance so global and session settings are both restored.
PrivaterowsPrivatestartPrivatestartStarts a DuckDB worker and instantiates DuckDB in it. With withoutOPFS,
the worker has no navigator.storage.getDirectory(), so DuckDB does not
mount its OPFS scratch file system.
Tokenizes SQL using DuckDB's internal parser via the poached extension.
Returns token positions and categories for syntax highlighting. Categories include: KEYWORD, IDENTIFIER, OPERATOR, NUMERIC_CONSTANT, STRING_CONSTANT, COMMENT, ERROR
The SQL string to tokenize
A promise that resolves to an array of tokens, or null if tokenization fails
Validates SQL and returns error information if invalid.
This combines is_valid_sql() and sql_error_message() in a single query
for efficiency. Returns validation result and error details in one call.
The SQL string to validate
A promise that resolves to an object with isValid boolean and
optional error with details, or undefined if extension unavailable
PrivatewithRuns connection work one operation at a time.
DuckDB-Wasm keys sent queries, result-chunk fetches, and cancellation by connection rather than by query, so a statement started while another result is still being read takes over that connection's result. Each operation therefore holds the connection until its result is fully consumed. cancelActiveQuery deliberately bypasses this queue.
Tail of the connection work queue; see Database.withConnection.