From e5c3c58f73d136c133210c0d9b3137a45e5d5d3c Mon Sep 17 00:00:00 2001 From: Rick Smit Date: Thu, 28 Dec 2023 19:17:06 +0000 Subject: [PATCH] add configuration options for DuckDB class (#200) * add configuration options for DuckDB class * Refactor DuckDB init statements. --------- Co-authored-by: Jeffrey Heer --- packages/duckdb/src/DuckDB.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/duckdb/src/DuckDB.js b/packages/duckdb/src/DuckDB.js index 3528c93f..1d109a62 100644 --- a/packages/duckdb/src/DuckDB.js +++ b/packages/duckdb/src/DuckDB.js @@ -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() {