Skip to content

Commit e5c3c58

Browse files
ricksmit3000jheer
andauthored
add configuration options for DuckDB class (#200)
* add configuration options for DuckDB class * Refactor DuckDB init statements. --------- Co-authored-by: Jeffrey Heer <[email protected]>
1 parent be2162f commit e5c3c58

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

packages/duckdb/src/DuckDB.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,23 @@ import { mergeBuffers } from './merge-buffers.js';
33

44
const TEMP_DIR = '.duckdb';
55

6-
const CONFIG = [
6+
const DEFAULT_INIT_STATEMENTS = [
77
`PRAGMA temp_directory='${TEMP_DIR}'`,
88
`INSTALL arrow`,
99
`INSTALL httpfs`,
1010
`LOAD arrow`,
1111
`LOAD httpfs`
12-
];
12+
].join(';\n');
1313

1414
export class DuckDB {
15-
constructor(path = ':memory:') {
16-
this.db = new duckdb.Database(path);
15+
constructor(
16+
path = ':memory:',
17+
config = {},
18+
initStatements = DEFAULT_INIT_STATEMENTS
19+
) {
20+
this.db = new duckdb.Database(path, config);
1721
this.con = this.db.connect();
18-
this.exec(CONFIG.join(';\n'));
22+
this.exec(initStatements);
1923
}
2024

2125
close() {

0 commit comments

Comments
 (0)