1 #include <det/VSQLManager_SQLite.h>
2 #include <utl/Reader.h>
3 #include <utl/AugerUnits.h>
4 #include <fwk/CentralConfig.h>
5 #include <fwk/CommandLineOptions.h>
6 #include <boost/algorithm/string.hpp>
19 const double time = fTime.GetTime();
22 info <<
"Total time spent for SQLite database '" << fDatabaseName
23 <<
"' queries is " << time/
second <<
" sec.";
29 sqlite3_exec(fDb,
"END TRANSACTION", 0, 0, 0);
33 fIsInitialized =
false;
41 const int rc = sqlite3_finalize(fResult);
51 return sqlite3_step(fResult);
59 fIsInitialized =
false;
61 fBranch.GetChild(
"databaseName").GetData(fDatabaseName);
62 fBranch.GetChild(
"softwareVersion").GetData(fDatabaseSoftwareVersion);
64 if (sqlite3_open_v2(fDatabaseName.c_str(), &fDb, SQLITE_OPEN_READONLY, 0)) {
66 err <<
VSQLManager::GetName() <<
" could not open the requested SQLite database file " << fDatabaseName << endl;
73 fIsInitialized =
true;
75 sqlite3_exec(fDb,
"PRAGMA cache_size=500000", 0, 0, 0);
76 sqlite3_exec(fDb,
"PRAGMA temp_store=MEMORY", 0, 0, 0);
77 sqlite3_exec(fDb,
"BEGIN TRANSACTION", 0, 0, 0);
85 if (!fIsInitialized) {
86 const string err =
"SQLite database is not opened.";
96 const char*
s =
nullptr;
98 const string queryMod = boost::replace_all_copy(query,
"UNIX_TIMESTAMP(",
"strftime('%s',");
99 const int rc = sqlite3_prepare_v2(fDb, queryMod.c_str(), queryMod.size(), &fResult, &
s);
105 cerr <<
"SQLite error " << rc
106 <<
": could not process the query \"" << query <<
"\"" << endl;
117 VManager::IndexMap::const_iterator it = componentIndex.begin();
118 res << it->first <<
" = " << it->second;
119 for (++it; it != componentIndex.end(); ++it)
120 res <<
" AND " << it->first <<
" = " << it->second;
#define INFO(message)
Macro for logging informational messages.
virtual void Init(const std::string &configLink)
Manager Initialization. configLink is the CentralConfig hook for the configuration file...
Base class to report exceptions in IO.
virtual void Init(const std::string &configLink)
Manager Initialization. configLink is the CentralConfig hook for the configuration file...
Status
Return code for seek operation.
const std::string & GetName() const
MYSQL_ROW FetchRow() const
Status Query(const std::ostringstream &os, const std::string &what="") const
query MySQL
static std::string MergeIndexMap(const IndexMap &componentIndex)
#define ERROR(message)
Macro for logging error messages.
Status
Specifies success or (eventually) various possible failure modes.