mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 04:26:01 +00:00
workign excel import
This commit is contained in:
@@ -14,6 +14,10 @@ export function getTargetName(source, values) {
|
||||
return source;
|
||||
}
|
||||
|
||||
export function isFileStorage(storageType) {
|
||||
return storageType == 'csv' || storageType == 'jsonl' || storageType == 'excel';
|
||||
}
|
||||
|
||||
async function getConnection(storageType, conid, database) {
|
||||
if (storageType == 'database') {
|
||||
const conn = await getConnectionInfo({ conid });
|
||||
@@ -41,6 +45,18 @@ function getSourceExpr(sourceName, values, sourceConnection, sourceDriver) {
|
||||
},
|
||||
];
|
||||
}
|
||||
if (isFileStorage(values.sourceStorageType)) {
|
||||
const sourceFile = values[`sourceFile_${sourceName}`];
|
||||
if (values.sourceStorageType == 'excel') {
|
||||
return ['excelSheetReader', sourceFile];
|
||||
}
|
||||
if (values.sourceStorageType == 'jsonl') {
|
||||
return ['jsonLinesReader', sourceFile];
|
||||
}
|
||||
if (values.sourceStorageType == 'csv') {
|
||||
return ['csvReader', sourceFile];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getFlagsFroAction(action) {
|
||||
@@ -106,20 +122,18 @@ export default async function createImpExpScript(values) {
|
||||
values.targetDatabaseName
|
||||
);
|
||||
|
||||
if (values.sourceStorageType == 'database') {
|
||||
const sourceList = getAsArray(values.sourceList);
|
||||
for (const sourceName of sourceList) {
|
||||
const sourceVar = script.allocVariable();
|
||||
// @ts-ignore
|
||||
script.assign(sourceVar, ...getSourceExpr(sourceName, values, sourceConnection, sourceDriver));
|
||||
const sourceList = getAsArray(values.sourceList);
|
||||
for (const sourceName of sourceList) {
|
||||
const sourceVar = script.allocVariable();
|
||||
// @ts-ignore
|
||||
script.assign(sourceVar, ...getSourceExpr(sourceName, values, sourceConnection, sourceDriver));
|
||||
|
||||
const targetVar = script.allocVariable();
|
||||
// @ts-ignore
|
||||
script.assign(targetVar, ...getTargetExpr(sourceName, values, targetConnection, targetDriver));
|
||||
const targetVar = script.allocVariable();
|
||||
// @ts-ignore
|
||||
script.assign(targetVar, ...getTargetExpr(sourceName, values, targetConnection, targetDriver));
|
||||
|
||||
script.copyStream(sourceVar, targetVar);
|
||||
script.put();
|
||||
}
|
||||
script.copyStream(sourceVar, targetVar);
|
||||
script.put();
|
||||
}
|
||||
return script.s;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user