mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-29 19:13:59 +00:00
fix: remove temp duckdb connection cache
This commit is contained in:
@@ -21,29 +21,16 @@ function getDuckDb() {
|
|||||||
return duckDb;
|
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>} */
|
/** @type {import('dbgate-types').EngineDriver<import('@duckdb/node-api').DuckDBConnection>} */
|
||||||
const driver = {
|
const driver = {
|
||||||
...driverBase,
|
...driverBase,
|
||||||
analyserClass: Analyser,
|
analyserClass: Analyser,
|
||||||
async connect({ databaseFile, isReadOnly }) {
|
async connect({ databaseFile, isReadOnly }) {
|
||||||
|
const instance = await getDuckDb().DuckDBInstance.create(databaseFile);
|
||||||
|
const connection = await instance.connect();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
client: await getConnection(databaseFile),
|
client: connection,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
async close(dbhan) {
|
async close(dbhan) {
|
||||||
|
|||||||
Reference in New Issue
Block a user