mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 02:06:01 +00:00
fix: remove temp duckdb connection cache
This commit is contained in:
@@ -21,29 +21,16 @@ function getDuckDb() {
|
||||
return duckDb;
|
||||
}
|
||||
|
||||
let fileToCon = {};
|
||||
async function getConnection(file) {
|
||||
if (fileToCon[file]) {
|
||||
fileToCon[file].close();
|
||||
}
|
||||
|
||||
const duckDb = getDuckDb();
|
||||
const instance = await duckDb.DuckDBInstance.create(file);
|
||||
console.log('DuckDB instance created', instance);
|
||||
const connection = await instance.connect();
|
||||
|
||||
fileToCon[file] = connection;
|
||||
|
||||
return fileToCon[file];
|
||||
}
|
||||
|
||||
/** @type {import('dbgate-types').EngineDriver<import('@duckdb/node-api').DuckDBConnection>} */
|
||||
const driver = {
|
||||
...driverBase,
|
||||
analyserClass: Analyser,
|
||||
async connect({ databaseFile, isReadOnly }) {
|
||||
const instance = await getDuckDb().DuckDBInstance.create(databaseFile);
|
||||
const connection = await instance.connect();
|
||||
|
||||
return {
|
||||
client: await getConnection(databaseFile),
|
||||
client: connection,
|
||||
};
|
||||
},
|
||||
async close(dbhan) {
|
||||
|
||||
Reference in New Issue
Block a user