Skip to content

Commit

Permalink
add configuration options for DuckDB class (#200)
Browse files Browse the repository at this point in the history
* add configuration options for DuckDB class

* Refactor DuckDB init statements.

---------

Co-authored-by: Jeffrey Heer <[email protected]>
  • Loading branch information
ricksmit3000 and jheer authored Dec 28, 2023
1 parent be2162f commit e5c3c58
Showing 1 changed file with 9 additions and 5 deletions.
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

0 comments on commit e5c3c58

Please sign in to comment.