Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add configuration options for DuckDB class #200

Merged
merged 2 commits into from
Dec 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions packages/duckdb/src/DuckDB.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,23 @@ import { mergeBuffers } from './merge-buffers.js';

const TEMP_DIR = '.duckdb';

const CONFIG = [
const DEFAULT_INIT_STATEMENTS = [
`PRAGMA temp_directory='${TEMP_DIR}'`,
`INSTALL arrow`,
`INSTALL httpfs`,
`LOAD arrow`,
`LOAD httpfs`
];
].join(';\n');

export class DuckDB {
constructor(path = ':memory:') {
this.db = new duckdb.Database(path);
constructor(
path = ':memory:',
config = {},
initStatements = DEFAULT_INIT_STATEMENTS
) {
this.db = new duckdb.Database(path, config);
this.con = this.db.connect();
this.exec(CONFIG.join(';\n'));
this.exec(initStatements);
}

close() {
Expand Down