PrivateactivePrivateconnPrivatedbPrivateinitializedPrivateinitialPrivateoptionsPrivatepoachedPrivateworkerWhether 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
PrivatereadPrivatereadRegisters 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
PrivatereinitializeRestores 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.
PrivaterowsPrivatestartSends a SQL query and returns Arrow record batches as row arrays.
This is intended for output modes that can display rows incrementally. Callers that need a fully materialized result should keep using executeQuery.
The SQL statement to execute
A stream result containing column metadata and async row batches
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
Cancels the query currently being consumed through DuckDB's pending-query API.