mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-22 14:36:01 +00:00
export from duckdb works
This commit is contained in:
@@ -131,6 +131,12 @@ module.exports = {
|
||||
socket.emit(`runner-done-${runid}`);
|
||||
},
|
||||
|
||||
handle_progress(conid, database, progressData) {
|
||||
const { progressName } = progressData;
|
||||
const { name, runid } = progressName;
|
||||
socket.emit(`runner-progress-${runid}`, { ...progressData, progressName: name });
|
||||
},
|
||||
|
||||
async ensureOpened(conid, database) {
|
||||
const existing = this.opened.find(x => x.conid == conid && x.database == database);
|
||||
if (existing) return existing;
|
||||
|
||||
@@ -8,7 +8,7 @@ const { fork, spawn } = require('child_process');
|
||||
const { rundir, uploadsdir, pluginsdir, getPluginBackendPath, packagedPluginList } = require('../utility/directories');
|
||||
const {
|
||||
extractShellApiPlugins,
|
||||
extractShellApiFunctionName,
|
||||
compileShellApiFunctionName,
|
||||
jsonScriptToJavascript,
|
||||
getLogger,
|
||||
safeJsonParse,
|
||||
@@ -58,7 +58,7 @@ dbgateApi.initializeApiEnvironment();
|
||||
${requirePluginsTemplate(extractShellApiPlugins(functionName, props))}
|
||||
require=null;
|
||||
async function run() {
|
||||
const reader=await ${extractShellApiFunctionName(functionName, true)}(${JSON.stringify(props)});
|
||||
const reader=await ${compileShellApiFunctionName(functionName)}(${JSON.stringify(props)});
|
||||
const writer=await dbgateApi.collectorWriter({runid: '${runid}'});
|
||||
await dbgateApi.copyStream(reader, writer);
|
||||
}
|
||||
@@ -273,7 +273,7 @@ module.exports = {
|
||||
const runid = crypto.randomUUID();
|
||||
|
||||
if (script.type == 'json') {
|
||||
const js = jsonScriptToJavascript(script);
|
||||
const js = await jsonScriptToJavascript(script);
|
||||
return this.startCore(runid, scriptTemplate(js, false));
|
||||
}
|
||||
|
||||
@@ -335,7 +335,7 @@ module.exports = {
|
||||
return { errorMessage: 'Only JSON scripts are allowed' };
|
||||
}
|
||||
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
const promise = new Promise(async (resolve, reject) => {
|
||||
const runid = crypto.randomUUID();
|
||||
this.requests[runid] = { resolve, reject, exitOnStreamError: true };
|
||||
const cloned = _.cloneDeepWith(script, node => {
|
||||
@@ -343,7 +343,7 @@ module.exports = {
|
||||
return runid;
|
||||
}
|
||||
});
|
||||
const js = jsonScriptToJavascript(cloned);
|
||||
const js = await jsonScriptToJavascript(cloned);
|
||||
this.startCore(runid, scriptTemplate(js, false));
|
||||
});
|
||||
return promise;
|
||||
|
||||
@@ -21,6 +21,9 @@ const { dumpSqlSelect } = require('dbgate-sqltree');
|
||||
const { allowExecuteCustomScript, handleQueryStream } = require('../utility/handleQueryStream');
|
||||
const dbgateApi = require('../shell');
|
||||
const requirePlugin = require('../shell/requirePlugin');
|
||||
const path = require('path');
|
||||
const { rundir } = require('../utility/directories');
|
||||
const fs = require('fs-extra');
|
||||
|
||||
const logger = getLogger('dbconnProcess');
|
||||
|
||||
@@ -411,9 +414,19 @@ async function handleExecuteSessionQuery({ sesid, sql }) {
|
||||
}
|
||||
|
||||
async function handleEvalJsonScript({ script, runid }) {
|
||||
const evalWriter = new ScriptWriterEval(dbgateApi, requirePlugin, dbhan);
|
||||
await playJsonScriptWriter(script, evalWriter);
|
||||
process.send({ msgtype: 'runnerDone', runid });
|
||||
const directory = path.join(rundir(), runid);
|
||||
fs.mkdirSync(directory);
|
||||
const originalCwd = process.cwd();
|
||||
|
||||
try {
|
||||
process.chdir(directory);
|
||||
|
||||
const evalWriter = new ScriptWriterEval(dbgateApi, requirePlugin, dbhan, runid);
|
||||
await playJsonScriptWriter(script, evalWriter);
|
||||
process.send({ msgtype: 'runnerDone', runid });
|
||||
} finally {
|
||||
process.chdir(originalCwd);
|
||||
}
|
||||
}
|
||||
|
||||
// async function handleRunCommand({ msgid, sql }) {
|
||||
|
||||
Reference in New Issue
Block a user