diff -r 19580b27ade2 -r eacacf060755 src/SqlHandler.h --- a/src/SqlHandler.h Tue Oct 22 16:05:36 2019 +0200 +++ b/src/SqlHandler.h Fri Oct 25 12:33:00 2019 +0200 @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -170,6 +171,29 @@ } } + std::vector getAllRelations() { + std::vector relations; + std::unique_ptr prepared(connection->prepareStatement("SELECT name FROM sqlite_master WHERE type IN ('table', 'view')")); + while (prepared->next()) relations.push_back(convertor.from_bytes(prepared->getString(0))); + return relations; + } + + void dumpRelations() { + std::wregex pattern(configuration.dumpRelations); + for (string_t relation : getAllRelations()) { + if (regex_match(relation, pattern)) { + std::wstringstream select; + select << L"SELECT * FROM "; + writeIdentifier(select, relation); + + Statement statement; + statement.relation = relation; + statement.sql = select.str(); + processStatement(statement); + } + } + } + relpipe::writer::string_t toSQLType(relpipe::reader::TypeId typeId) { if (typeId == relpipe::reader::TypeId::BOOLEAN) return L"integer"; // TODO: map selected values back to booleans or allow optional storage as string else if (typeId == relpipe::reader::TypeId::INTEGER) return L"integer"; @@ -279,6 +303,9 @@ // run the transformation – process all statements: for (const Statement& statement : configuration.statements) processStatement(statement); + // pass-through some relations: + if (configuration.dumpRelations.size()) dumpRelations(); + // delete or keep the file: if (configuration.file.size()) { if (configuration.keepFile == KeepFile::Never || (configuration.keepFile == KeepFile::Automatic && !fileAlreadyExisted)) {