15 #include "eckit/io/FileHandle.h"
16 #include "eckit/io/Length.h"
17 #include "eckit/io/PartFileHandle.h"
18 #include "eckit/io/FileDescHandle.h"
19 #include "eckit/utils/StringTools.h"
21 #include "eckit/sql/SQLParser.h"
22 #include "eckit/sql/SQLSelectFactory.h"
23 #include "eckit/sql/SQLSession.h"
24 #include "eckit/sql/SQLStatement.h"
25 #include "eckit/types/Types.h"
32 using namespace eckit;
39 SQLTool::SQLTool(
int argc,
char **argv) :
60 std::string fieldDelimiter =
optionArgument(
"-delimiter", std::string(
"\t"));
61 std::string outputFormat =
optionArgument(
"-f", std::string(eckit::sql::SQLOutputConfig::defaultOutputFormat));
64 bool noColumnAlignment =
optionIsSet(
"--no_alignment");
69 bitfieldsBinary, noColumnAlignment, fullPrecision));
74 if (outputFile ==
"-")
75 outputFile =
"/dev/stdout";
77 if (!outputFile.empty()) {
97 ? StringTools::join(
" ",
params) +
";"
102 std::unique_ptr<std::ofstream> outStream;
104 outStream.reset(
new std::ofstream(
optionArgument(
"-o", std::string(
"")).c_str()));
111 std::unique_ptr<eckit::DataHandle> implicitTableDH;
115 Log::info() <<
"Reading table from standard input" << std::endl;
116 implicitTableDH.reset(
new FileDescHandle(0));
119 }
else if (
offset_ == eckit::Offset(0)) {
120 implicitTableDH.reset(
new FileHandle(
inputFile_));
125 implicitTableDH->openForRead();
127 eckit::sql::SQLDatabase& db(session.currentDatabase());
133 eckit::sql::SQLParser
parser;
134 parser.parseString(session, sql);
135 session.statement().execute();