workign excel import

This commit is contained in:
Jan Prochazka
2020-06-18 15:08:58 +02:00
parent 967c5860c9
commit 8425fc46a7
6 changed files with 196 additions and 20 deletions

View File

@@ -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;
}