PrivateconnPrivatedbPrivateinitializedPrivateoptionsPrivatepoachedPrivateworkerExecutes 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
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
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
Registers 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
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
Closes the database connection and releases resources.
This method:
After calling this method, init must be called again before executing any queries.