Skip to content

@sqlrooms/duckdb / DuckDbConnector

Interface: DuckDbConnector

Methods

initialize()

initialize(): Promise<void>

Initialize the connector

Returns

Promise<void>


destroy()

destroy(): Promise<void>

Destroy the connector and clean up resources

Returns

Promise<void>


query()

query(query): Promise<Table<any>>

Execute a SQL query and return the result as an Arrow table

Parameters

ParameterTypeDescription
querystringSQL query to execute

Returns

Promise<Table<any>>


loadFile()

loadFile(fileName, tableName, opts?): Promise<void>

Load a file into DuckDB and create a table

Parameters

ParameterTypeDescription
fileNamestring | FilePath to the file to load
tableNamestringName 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>


loadArrow()

loadArrow(table, tableName, opts?): Promise<void>

Load an arrow table or an arrow IPC stream into DuckDB

Parameters

ParameterTypeDescription
tableTable<any> | Uint8Array<ArrayBufferLike>Arrow table or arrow IPC stream to load
tableNamestringName of the table to create
opts?{ schema: string; }-
opts.schema?string-

Returns

Promise<void>


loadObjects()

loadObjects(data, tableName, opts?): Promise<void>

Load JavaScript objects into DuckDB

Parameters

ParameterTypeDescription
dataRecord<string, unknown>[]Array of objects to load
tableNamestringName 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>