configurations for DuckDbDialect
OptionalonCreateConnection?: (connection: AsyncDuckDBConnection) => Promise<void>Mappings of table name in kysely to duckdb table expressions.
Duckdb can read external source(file, url or database) as table
like: SELECT * FROM read_json_objects('path/to/file/*.json').
You can use raw duckdb table expression as table name, but it may be too
long, preserving too many implementation details.
This mappings is used to replace table name string to duckdb table expression.
const dialect = new DuckDbDialect({
database: db,
tableMappings: {
person: 'read_json_object("s3://my-bucket/person.json?s3_access_key_id=key&s3_secret_access_key=secret")'
}
});
const db = new Kysely<{
person: { first_name: string, last_name: string }, // 'person' is defined in tableMappings
pet: { name: string, species: 'cat' | 'dog' }, // 'pet' is *not* defined in tableMappings
>({ dialect });
await db.selectFrom("person").selectAll().execute();
// => Executed query is: `SELECT * FROM read_json_object("s3://my-bucket/person.json?s3_access_key_id=key&s3_secret_access_key=secret");`
await db.selectFrom("pet").selectAll().execute();
// => Executed query is: SELECT * FROM pet;
Creates an adapter for the dialect.
Creates a driver for the dialect.
Creates a database introspector that can be used to get database metadata such as the table names and column names of those tables.
db never has any plugins installed. It's created using
Kysely.withoutPlugins.
Creates a query compiler for the dialect.
Kysely dialect for duckdb.
Quick Start and Usage Example
Please see also Kysely Docs and Duckdb Docs
Install
Basic Usage Example
reading data from json file.