Skip to content

Query Builder Import & Exports

Getting started

import { Database } from '@sluice/adbc';
import SluiceDuckDBDialect, { KyselyDuckDB } from '@sluice/kysely-duckdb-adbc';
const adbc = new Database(':memory:');
const db = new KyselyDuckDB({ dialect: new SluiceDuckDBDialect({ database: adbc }) });

Import Tables

await db.importCSV('season', './fixtures/season.csv', {
createTable: false,
autoDetect: false,
header: true,
delimiter: '|',
columns: {
season: 'BIGINT',
id: 'BIGINT',
name: 'TEXT',
start: 'TIMESTAMP',
end: 'TIMESTAMP',
years_start: 'BIGINT',
years_end: 'BIGINT',
created_date: 'TIMESTAMP',
last_updated: 'TIMESTAMP',
},
});

Export Tables

await db.exportCSV('season', './out/season.csv', {
header: true,
delimiter: '|',
});

Export Database

// creates a copy as a single duckdb file
await db.exportDuckDB('./out/export.duckdb');

Import Database

// imports all or specified tables from a duckdb file
await db.importDuckDB('./out/import.duckdb', { tables: ['season'] });