@sqlrooms/duckdb / WasmDuckDbConnector
Class: WasmDuckDbConnector
Extends
Constructors
new WasmDuckDbConnector()
new WasmDuckDbConnector(
__namedParameters
):WasmDuckDbConnector
Parameters
Parameter | Type |
---|---|
__namedParameters | { dbPath : string ; queryConfig : DuckDBQueryConfig ; initializationQuery : string ; logging : boolean ; } |
__namedParameters.dbPath ? | string |
__namedParameters.queryConfig ? | DuckDBQueryConfig |
__namedParameters.initializationQuery ? | string |
__namedParameters.logging ? | boolean |
Returns
Overrides
BaseDuckDbConnector
.constructor
Properties
Property | Modifier | Type | Default value | Inherited from |
---|---|---|---|---|
dbPath | protected | string | undefined | BaseDuckDbConnector .dbPath |
initializationQuery | protected | string | undefined | BaseDuckDbConnector .initializationQuery |
initialized | protected | boolean | false | BaseDuckDbConnector .initialized |
initializing | protected | null | Promise <void > | null | BaseDuckDbConnector .initializing |
logging | private | boolean | undefined | - |
db | private | null | AsyncDuckDB | null | - |
conn | private | null | AsyncDuckDBConnection | null | - |
worker | private | null | Worker | null | - |
queryConfig? | private | DuckDBQueryConfig | undefined | - |
Methods
initialize()
initialize():
Promise
<void
>
Initialize the connector
Returns
Promise
<void
>
Inherited from
BaseDuckDbConnector
.initialize
ensureInitialized()
protected
ensureInitialized():Promise
<void
>
Returns
Promise
<void
>
Inherited from
BaseDuckDbConnector
.ensureInitialized
initializeInternal()
protected
initializeInternal():Promise
<void
>
Returns
Promise
<void
>
Overrides
BaseDuckDbConnector
.initializeInternal
destroy()
destroy():
Promise
<void
>
Destroy the connector and clean up resources
Returns
Promise
<void
>
Overrides
query()
query(
query
):Promise
<Table
<any
>>
Execute a SQL query and return the result as an Arrow table
Parameters
Parameter | Type | Description |
---|---|---|
query | string | SQL query to execute |
Returns
Promise
<Table
<any
>>
Overrides
loadFile()
loadFile(
file
,tableName
,opts
?):Promise
<void
>
Load a file into DuckDB and create a table
Parameters
Parameter | Type | Description |
---|---|---|
file | string | File | - |
tableName | string | Name of the table to create |
opts ? | objectOutputType <extendShape <{ schema : ZodOptional <ZodString >; select : ZodOptional <ZodArray <ZodString , "many" >>; where : ZodOptional <ZodString >; view : ZodOptional <ZodBoolean >; temp : ZodOptional <ZodBoolean >; replace : ZodOptional <ZodBoolean >; }, { method : ZodEnum <["read_json" , "read_ndjson" , "read_parquet" , "read_csv" , "auto" ]>; }>, ZodUnknown , "strip" > | objectOutputType <extendShape <extendShape <{ schema : ZodOptional <ZodString >; select : ZodOptional <ZodArray <ZodString , "many" >>; where : ZodOptional <ZodString >; view : ZodOptional <ZodBoolean >; temp : ZodOptional <ZodBoolean >; replace : ZodOptional <ZodBoolean >; }, { options : ZodOptional <ZodUnion <[ZodArray <ZodString , "many" >, ZodString , ZodRecord <ZodString , ZodUnknown >]>>; }>, { method : ZodLiteral <"st_read" >; }>, ZodUnknown , "strip" > | Load options |
Returns
Promise
<void
>
Overrides
loadArrow()
loadArrow(
file
,tableName
,opts
?):Promise
<void
>
Load an arrow table or an arrow IPC stream into DuckDB
Parameters
Parameter | Type | Description |
---|---|---|
file | Table <any > | Uint8Array <ArrayBufferLike > | - |
tableName | string | Name of the table to create |
opts ? | { schema : string ; } | - |
opts.schema ? | string | - |
Returns
Promise
<void
>
Overrides
loadObjects()
loadObjects(
file
,tableName
,opts
?):Promise
<void
>
Load JavaScript objects into DuckDB
Parameters
Parameter | Type | Description |
---|---|---|
file | Record <string , unknown >[] | - |
tableName | string | Name of the table to create |
opts ? | objectOutputType <{ schema : ZodOptional <ZodString >; select : ZodOptional <ZodArray <ZodString , "many" >>; where : ZodOptional <ZodString >; view : ZodOptional <ZodBoolean >; temp : ZodOptional <ZodBoolean >; replace : ZodOptional <ZodBoolean >; }, ZodUnknown , "strip" > | Load options |
Returns
Promise
<void
>
Overrides
BaseDuckDbConnector
.loadObjects
withTempRegisteredFile()
private
withTempRegisteredFile(file
,action
):Promise
<void
>
Parameters
Parameter | Type |
---|---|
file | string | File |
action | (fileName ) => Promise <void > |
Returns
Promise
<void
>
getDb()
getDb():
AsyncDuckDB
Returns
AsyncDuckDB
getConnection()
getConnection():
AsyncDuckDBConnection
Returns
AsyncDuckDBConnection