Skip to content

@sqlrooms/duckdb / DuckDbSliceState

Type Alias: DuckDbSliceState

DuckDbSliceState = object

State and actions for the DuckDB slice

Properties

db

db: object

NameTypeDescription
connectorDuckDbConnectorThe DuckDB connector instance
schemastringDeprecated We shouldn't limit the schema to a single one.
currentSchemastring | undefined-
currentDatabasestring | undefined-
tablesDataTable[]Cache of refreshed table schemas
tableRowCounts{[tableName: string]: number; }Cache of row counts for tables
schemaTrees?DbSchemaNode[]Cache of schema trees for tables
queryCache{[key: string]: QueryHandle; }Cache of currently running query handles. This is only used for running queries to deduplicate them (especially for useSql), the cache is cleared when the query is completed.
isRefreshingTableSchemasbooleanWhether the table schemas are being refreshed
setConnector()(connector) => voidSet a new DuckDB connector
initialize()() => Promise<void>Initialize the connector (creates a WasmDuckDbConnector if none exists)
destroy()() => Promise<void>Close and clean up the connector
addTable()(tableName, data) =>-
loadTableSchemas()(filter?) =>-
getTable()(tableName) =>-
setTableRowCount()(tableName, rowCount) =>-
findTableByName()(tableName) =>-
refreshTableSchemas()() =>-
getConnector()() => Promise<DuckDbConnector>Get the connector. If it's not initialized, it will be initialized.
getTableRowCount()(table, schema?) => Promise<number>Deprecated Use .loadTableRowCount() instead
loadTableRowCount()(tableName) => Promise<number>Load the row count of a table
executeSql()(query, version?) => Promise<QueryHandle | null>Execute a query with query handle (not result) caching and deduplication
getTables()(schema?) => Promise<string[]>Deprecated Use .tables or .loadTableSchemas() instead
getTableSchema()(tableName, schema?) => Promise<DataTable | undefined>Deprecated Use .loadTableSchemas() instead
getTableSchemas()(schema?) => Promise<DataTable[]>Deprecated Use .tables or .loadTableSchemas() instead
checkTableExists()(tableName) => Promise<boolean>Check if a table exists
dropTable()(tableName) => Promise<void>Delete a table with optional schema and database
createTableFromQuery()(tableName, query, options?) => Promise<{ tableName: string | QualifiedTableName; rowCount: number | undefined; }>Create a table or view from a query.
sqlSelectToJson()(sql) => Promise<{ error: true; error_type: string; error_message: string; error_subtype: string; position: string; } | { error: false; statements: object[]; }>Parse a SQL SELECT statement to JSON