JAPAn
Just Another Parity Analyzer
Loading...
Searching...
No Matches
QwDatabase.cc
Go to the documentation of this file.
1/*!
2 * \file QwDatabase.cc
3 * \brief A class for handling connections to the Qweak database.
4 *
5 * \author Damon Spayde
6 * \date 2010-01-07
7 */
8
9
10#include "QwDatabase.h"
11
12// System headers
13
14// Third-party headers
15#ifdef __USE_SQLPP11__
16#include <sqlpp11/select.h>
17#include <sqlpp11/functions.h>
18#endif // __USE_SQLPP11__
19#ifdef __USE_SQLPP23__
20#include <sqlpp23/core/clause/select.h>
21#include <sqlpp23/core/function.h>
22#endif // __USE_SQLPP23__
23
24// Qweak headers
25#include "QwParitySchema.h"
26
27// QwScopedConnection implementation
29 : fDatabase(db), fConnected(false) {
30 if (fDatabase) {
31 fConnected = fDatabase->Connect();
32 if (!fConnected) {
33 QwError << "QwScopedConnection: Failed to establish database connection" << QwLog::endl;
34 }
35 }
36}
37
39 if (fDatabase && fConnected) {
40 fDatabase->Disconnect();
41 fConnected = false;
42 }
43}
44
46 : fDatabase(other.fDatabase), fConnected(other.fConnected) {
47 other.fDatabase = nullptr;
48 other.fConnected = false;
49}
50
52 if (this != &other) {
53 // Clean up current connection
54 if (fDatabase && fConnected) {
55 fDatabase->Disconnect();
56 }
57
58 // Move from other
59 fDatabase = other.fDatabase;
60 fConnected = other.fConnected;
61
62 // Clear other
63 other.fDatabase = nullptr;
64 other.fConnected = false;
65 }
66 return *this;
67}
68
70 return fConnected && fDatabase && fDatabase->Connected();
71}
72
73
74/*! The simple constructor initializes member fields. This class is not
75 * used to establish the database connection.
76 */
77//QwDatabase::QwDatabase() : Connection(false)
78QwDatabase::QwDatabase(const string &major, const string &minor, const string &point) : kValidVersionMajor(major), kValidVersionMinor(minor), kValidVersionPoint(point)
79{
80 QwDebug << "Greetings from QwDatabase simple constructor." << QwLog::endl;
81
82 // Initialize member fields
85
87
88 fDBPortNumber = 0;
89 fValidConnection = false;
90
91}
92
93/*! The constructor initializes member fields using the values in
94 * the QwOptions object.
95 * @param options The QwOptions object.
96 * @param major Major version number
97 * @param minor Minor version number
98 * @param point Point revision number
99 */
100QwDatabase::QwDatabase(QwOptions &options, const string &major, const string &minor, const string &point) : kValidVersionMajor(major), kValidVersionMinor(minor), kValidVersionPoint(point)
101{
102 QwDebug << "Greetings from QwDatabase extended constructor." << QwLog::endl;
103
104 // Initialize member fields
107
109
110 fDBPortNumber = 0;
111 fValidConnection = false;
112
113 ProcessOptions(options);
114
115}
116
117/*! The destructor says "Good-bye World!"
118 */
120{
121 QwDebug << "QwDatabase::~QwDatabase() : Good-bye World from QwDatabase destructor!" << QwLog::endl;
122 if (Connected()) Disconnect();
123}
124
125/*! This function is used to load the connection information for the
126 * database. It tests the connection to make sure it is valid and causes a
127 * program exit if no valid connection can be formed.
128 *
129 * It is called the first time Connect() is called.
130 */
132{
133 QwDebug << "Entering QwDatabase::ValidateConnection()..." << QwLog::endl;
134
135 // Bool_t status;
136 //
137 // Retrieve options if they haven't already been filled.
138 //
139 // if (fDatabase.empty()){
140 // status = ProcessOptions(gQwOptions);
141 // if (!status) return status;
142 // }
143
144 // Check values.
146 if (fDatabase.empty()){
147 QwError << "QwDatabase::ValidateConnection() : No database supplied. Unable to connect." << QwLog::endl;
148 fValidConnection=false;
149 }
150#ifdef __USE_DATABASE_SQLITE3__
151 if (fDBType != kQwDatabaseSQLite3) {
152#else
153 // If SQLite3 is not available, all databases require username/password
154 if (true) {
155#endif
156 if (fDBUsername.empty()){
157 QwError << "QwDatabase::ValidateConnection() : No database username supplied. Unable to connect." << QwLog::endl;
158 fValidConnection=false;
159 }
160 if (fDBPassword.empty()){
161 QwError << "QwDatabase::ValidateConnection() : No database password supplied. Unable to connect." << QwLog::endl;
162 fValidConnection=false;
163 }
164 if (fDBServer.empty()){
165 QwMessage << "QwDatabase::ValidateConnection() : No database server supplied. Attempting localhost." << QwLog::endl;
166 fDBServer = "localhost";
167 }
168 }
169 //
170 // Try to connect with given information
171 //
172 try {
173 // FIXME (wdconinc) duplication with Connect
174 switch(fDBType)
175 {
176#ifdef __USE_DATABASE_MYSQL__
177 case kQwDatabaseMySQL: {
178 QwDebug << "QwDatabase::ValidateConnection() : Using MySQL backend." << QwLog::endl;
179 sqlpp::mysql::connection_config config;
180 config.host = fDBServer;
181 config.user = fDBUsername;
182 config.password = fDBPassword;
183 config.database = fDatabase;
184 config.port = fDBPortNumber;
185#ifdef __USE_SQLPP11__
186 config.debug = fDBDebug;
187#endif
188#ifdef __USE_SQLPP23__
189 if (fDBDebug) {
190 config.debug = sqlpp::debug_logger({sqlpp::log_category::all}, [](const std::string& msg) {
191 QwMessage << "SQL Debug: " << msg << QwLog::endl;
192 });
193 }
194#endif
195 fDBConnection = std::make_shared<sqlpp::mysql::connection>(config);
196 break;
197 }
198#endif
199#ifdef __USE_DATABASE_SQLITE3__
200 case kQwDatabaseSQLite3: {
201 QwDebug << "QwDatabase::ValidateConnection() : Using SQLite3 backend." << QwLog::endl;
202 sqlpp::sqlite3::connection_config config;
203 config.path_to_database = fDatabase;
204 config.password = fDBPassword;
205 // FIXME (wdconinc) use proper access flags
206 config.flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
207#ifdef __USE_SQLPP11__
208 config.debug = fDBDebug;
209#endif
210#ifdef __USE_SQLPP23__
211 if (fDBDebug) {
212 config.debug = sqlpp::debug_logger({sqlpp::log_category::all}, [](const std::string& msg) {
213 QwMessage << "SQL Debug: " << msg << QwLog::endl;
214 });
215 }
216#endif
217 fDBConnection = std::make_shared<sqlpp::sqlite3::connection>(config);
218 break;
219 }
220#endif
221#ifdef __USE_DATABASE_POSTGRESQL__
222 case kQwDatabasePostgreSQL: {
223 QwDebug << "QwDatabase::ValidateConnection() : Using PostgreSQL backend." << QwLog::endl;
224 sqlpp::postgresql::connection_config config;
225 config.host = fDBServer;
226 config.user = fDBUsername;
227 config.password = fDBPassword;
228 config.dbname = fDatabase;
229 config.port = fDBPortNumber;
230#ifdef __USE_SQLPP11__
231 config.debug = fDBDebug;
232#endif
233#ifdef __USE_SQLPP23__
234 if (fDBDebug) {
235 config.debug = sqlpp::debug_logger({sqlpp::log_category::all}, [](const std::string& msg) {
236 QwMessage << "SQL Debug: " << msg << QwLog::endl;
237 });
238 }
239#endif
240 fDBConnection = std::make_shared<sqlpp::postgresql::connection>(config);
241 break;
242 }
243#endif
244 default: {
245 QwError << "QwDatabase::ValidateConnection() : Unsupported database type." << QwLog::endl;
247 return false;
248 }
249 }
250 } catch (std::exception const& e) {
251 QwError << "QwDatabase::ValidateConnection() : " << QwLog::endl;
252 QwError << e.what() << " while validating connection" << QwLog::endl;
253 QwError << "Database name = " << fDatabase <<QwLog::endl;
254 QwError << "Database server = " << fDBServer <<QwLog::endl;
255 QwError << "Database username = " << fDBUsername <<QwLog::endl;
256 QwError << "Database port = " << fDBPortNumber <<QwLog::endl;
257 QwError << "Continuing without database." << QwLog::endl;
258 QwWarning << "Might have left database connection dangling..." << QwLog::endl;
260 return kFALSE;
261 }
262
263 QwDebug << "QwDatabase::ValidateConnection() : Made it past connect() call." << QwLog::endl;
264
265 // Get database schema version information
266 if (StoreDBVersion()) {
267 fValidConnection = true;
268 // Success!
269 QwMessage << "QwDatabase::ValidateConnection() : Successfully connected to requested database." << QwLog::endl;
270 } else {
271 QwError << "QwDatabase::ValidateConnection() : Unsuccessfully connected to requested database." << QwLog::endl;
272 // Connection was bad so clear the member variables
273 fValidConnection = false;
274 fDatabase.clear();
275 fDBServer.clear();
276 fDBUsername.clear();
277 fDBPassword.clear();
279 }
280 Disconnect();
281 }
282
283 // Check to make sure database and QwDatabase schema versions match up.
288 fValidConnection = false;
289 QwError << "QwDatabase::ValidConnection() : Connected database schema inconsistent with current version of analyzer." << QwLog::endl;
290 QwError << " Database version is " << this->GetVersion() << QwLog::endl;
291 QwError << " Required database version is " << this->GetValidVersion() << QwLog::endl;
292 QwError << " Please connect to a database supporting the required schema version." << QwLog::endl;
293 exit(1);
294 }
295
296 QwDebug << "QwDatabase::ValidateConnection() : Exiting successfully." << QwLog::endl;
297 return fValidConnection;
298}
299
300
301/*! This function is used to initiate a database connection.
302 */
304{
305 /* Open a connection to the database using the predefined parameters.
306 * Must call QwDatabase::ConnectionInfo() first.
307 */
308
309 // Return false, if we're not using the DB.
310 if (fAccessLevel==kQwDatabaseOff) return false;
311
312 // Make sure not already connected
313 if (Connected()) return true;
314
315 // If never connected before, then make sure connection parameters form
316 // valid connection
317 if (!fValidConnection) {
319 }
320
321 if (fValidConnection) {
322 // FIXME (wdconinc) duplication with ValidateConnection
323 try {
324 switch(fDBType)
325 {
326#ifdef __USE_DATABASE_MYSQL__
327 case kQwDatabaseMySQL: {
328 QwDebug << "QwDatabase::ValidateConnection() : Using MySQL backend." << QwLog::endl;
329 sqlpp::mysql::connection_config config;
330 config.host = fDBServer;
331 config.user = fDBUsername;
332 config.password = fDBPassword;
333 config.database = fDatabase;
334 config.port = fDBPortNumber;
335#ifdef __USE_SQLPP11__
336 config.debug = fDBDebug;
337#endif
338#ifdef __USE_SQLPP23__
339 if (fDBDebug) {
340 config.debug = sqlpp::debug_logger({sqlpp::log_category::all}, [](const std::string& msg) {
341 QwMessage << "SQL Debug: " << msg << QwLog::endl;
342 });
343 }
344#endif
345 fDBConnection = std::make_shared<sqlpp::mysql::connection>(config);
346 break;
347 }
348#endif
349#ifdef __USE_DATABASE_SQLITE3__
350 case kQwDatabaseSQLite3: {
351 QwDebug << "QwDatabase::ValidateConnection() : Using SQLite3 backend." << QwLog::endl;
352 sqlpp::sqlite3::connection_config config;
353 config.path_to_database = fDatabase;
354 config.password = fDBPassword;
355 // FIXME (wdconinc) use proper access flags
356 config.flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
357#ifdef __USE_SQLPP11__
358 config.debug = fDBDebug;
359#endif
360#ifdef __USE_SQLPP23__
361 if (fDBDebug) {
362 config.debug = sqlpp::debug_logger({sqlpp::log_category::all}, [](const std::string& msg) {
363 QwMessage << "SQL Debug: " << msg << QwLog::endl;
364 });
365 }
366#endif
367 fDBConnection = std::make_shared<sqlpp::sqlite3::connection>(config);
368 break;
369 }
370#endif
371#ifdef __USE_DATABASE_POSTGRESQL__
372 case kQwDatabasePostgreSQL: {
373 QwDebug << "QwDatabase::ValidateConnection() : Using PostgreSQL backend." << QwLog::endl;
374 sqlpp::postgresql::connection_config config;
375 config.host = fDBServer;
376 config.user = fDBUsername;
377 config.password = fDBPassword;
378 config.dbname = fDatabase;
379 config.port = fDBPortNumber;
380 fDBConnection = std::make_shared<sqlpp::postgresql::connection>(config);
381 break;
382 }
383#endif
384 default: {
385 QwError << "QwDatabase::ValidateConnection() : Unsupported database type." << QwLog::endl;
386 return false;
387 }
388 }
389 } catch (const std::exception& e) {
390 QwError << "QwDatabase::Connect() : " << QwLog::endl;
391 QwError << e.what() << " while connecting to database" << QwLog::endl;
392 fValidConnection = false;
393 return false;
394 }
395 return true;
396 } else {
397 QwError << "QwDatabase::Connect() : Must establish valid connection to database." << QwLog::endl;
398 return false;
399 }
400}
401
402/*!
403 * Defines configuration options for QwDatabase class using QwOptions
404 * functionality.
405 *
406 * Should apparently by called by QwOptions::DefineOptions() in
407 * QwParityOptions.h
408 */
410{
411 // Specify command line options for use by QwDatabase
412 // FIXME (wdconinc) add database type option
413 options.AddOptions("Database options")("QwDatabase.accesslevel", po::value<string>(), "database access level (OFF,RO,RW)");
414 options.AddOptions("Database options")("QwDatabase.dbname", po::value<string>(), "database name or path");
415 options.AddOptions("Database options")("QwDatabase.dbserver", po::value<string>(), "database server name");
416 options.AddOptions("Database options")("QwDatabase.dbusername", po::value<string>(), "database username");
417 options.AddOptions("Database options")("QwDatabase.dbpassword", po::value<string>(), "database password");
418 options.AddOptions("Database options")("QwDatabase.dbport", po::value<int>()->default_value(0), "database server port number (defaults to standard mysql port)");
419 options.AddOptions("Database options")("QwDatabase.debug", po::value<bool>()->default_value(false), "enable database debug output (default false)");
420 options.AddOptions("Database options")("QwDatabase.insert-missing-keys", po::value<bool>()->default_value(false), "insert missing keys into the database (default false)");
421
422 std::stringstream dbtypes;
423 dbtypes << "none";
424#ifdef __USE_DATABASE_SQLITE3__
425 dbtypes << ",sqlite3";
426#endif // __USE_DATABASE_SQLITE3__
427#ifdef __USE_DATABASE_MYSQL__
428 dbtypes << ",mysql";
429#endif // __USE_DATABASE_MYSQL__
430#ifdef __USE_DATABASE_POSTGRESQL__
431 dbtypes << ",postgresql";
432#endif // __USE_DATABASE_POSTGRESQL__
433 std::stringstream desc;
434 desc << "database type (" << dbtypes.str() << ")";
435 options.AddOptions("Database options")("QwDatabase.dbtype", po::value<string>()->default_value("none"), desc.str().c_str());
436}
437
438/*!
439 * Loads the configuration options for QwDatabase class into this instance of
440 * QwDatabase from the QwOptions object.
441 * @param options Options object
442 */
444{
445 if (options.HasValue("QwDatabase.accesslevel")) {
446 string access = options.GetValue<string>("QwDatabase.accesslevel");
447 SetAccessLevel(access);
448 }
449 else {
450 QwWarning << "QwDatabase::ProcessOptions : No access level specified; database access is OFF" << QwLog::endl;
452 }
453 if (options.HasValue("QwDatabase.dbtype")) {
454 string dbtype = options.GetValue<string>("QwDatabase.dbtype");
456#ifdef __USE_DATABASE_MYSQL__
457 if (dbtype == "mysql") {
458 fDBType = kQwDatabaseMySQL;
459 }
460#endif
461#ifdef __USE_DATABASE_SQLITE3__
462 if (dbtype == "sqlite3") {
463 fDBType = kQwDatabaseSQLite3;
464 }
465#endif
466#ifdef __USE_DATABASE_POSTGRESQL__
467 if (dbtype == "postgresql") {
468 fDBType = kQwDatabasePostgreSQL;
469 }
470#endif
471 if (fDBType == kQwDatabaseNone) {
472 QwWarning << "QwDatabase::ProcessOptions : Unrecognized database type \"" << dbtype << "\"; using none" << QwLog::endl;
473 }
474 } else {
475 QwMessage << "QwDatabase::ProcessOptions : No database type specified" << QwLog::endl;
477 }
478 if (options.HasValue("QwDatabase.dbport")) {
479 fDBPortNumber = options.GetValue<int>("QwDatabase.dbport");
480 }
481 if (options.HasValue("QwDatabase.dbname")) {
482 fDatabase = options.GetValue<string>("QwDatabase.dbname");
483 }
484 if (options.HasValue("QwDatabase.dbusername")) {
485 fDBUsername = options.GetValue<string>("QwDatabase.dbusername");
486 }
487 if (options.HasValue("QwDatabase.dbpassword")) {
488 fDBPassword = options.GetValue<string>("QwDatabase.dbpassword");
489 }
490 if (options.HasValue("QwDatabase.dbserver")) {
491 fDBServer = options.GetValue<string>("QwDatabase.dbserver");
492 }
493 if (options.HasValue("QwDatabase.debug")) {
494 fDBDebug = options.GetValue<bool>("QwDatabase.debug");
495 }
496 if (options.HasValue("QwDatabase.insert-missing-keys")) {
497 fDBInsertMissingKeys = options.GetValue<bool>("QwDatabase.insert-missing-keys");
498 }
499}
500
501void QwDatabase::ProcessOptions(const EQwDBType& dbtype, const TString& dbname, const TString& username, const TString& passwd, const TString& dbhost, const Int_t dbport, const TString& accesslevel)
502{
503 SetAccessLevel(static_cast<string>(accesslevel));
504 fDBType = dbtype;
505 fDatabase = dbname;
506 fDBUsername = username;
507 fDBPassword = passwd;
508 fDBServer = dbhost;
509 fDBPortNumber = dbport;
510}
511
512void QwDatabase::SetAccessLevel(string accesslevel)
513{
514 TString level = accesslevel.c_str();
515 level.ToLower();
516 if (level=="off") fAccessLevel = kQwDatabaseOff;
517 else if (level=="ro") fAccessLevel = kQwDatabaseReadOnly;
518 else if (level=="rw") fAccessLevel = kQwDatabaseReadWrite;
519 else{
520 QwWarning << "QwDatabase::SetAccessLevel : Unrecognized access level \""
521 << accesslevel << "\"; setting database access OFF"
522 << QwLog::endl;
524 }
525 return;
526}
527
528/*!
529 * This function prints the server information.
530 */
532{
534 {
535 printf("\nQwDatabase MySQL ");
536 printf("%s v%s %s -----------------\n", BOLD, GetServerVersion().c_str(), NORMAL);
537 printf("Database server : %s%10s%s", RED, fDBServer.c_str(), NORMAL);
538 printf(" name : %s%12s%s", BLUE, fDatabase.c_str(), NORMAL);
539 printf(" user : %s%6s%s", RED, fDBUsername.c_str(), NORMAL);
540 printf(" port : %s%6d%s\n", BLUE, fDBPortNumber, NORMAL);
541 // FIXME (wdconinc) implement server_status();
542 //printf(" %s\n\n", server_status().c_str());
543 }
544 else
545 {
546 printf("There is no connection.\n");
547 }
548
549 return;
550}
551
552
554 string version = fVersionMajor + "." + fVersionMinor + "." + fVersionPoint;
555 return version;
556}
557
559 string version = kValidVersionMajor + "." + kValidVersionMinor + "." + kValidVersionPoint;
560 return version;
561}
562
563/*
564 * Retrieves database schema version information from database.
565 * Returns true if successful, false otherwise.
566 */
568{
569 try
570 {
571 QwParitySchema::db_schema db_schema;
572 size_t record_count = QueryCount(
573 sqlpp::select(sqlpp::all_of(db_schema))
574 .from(db_schema)
575 .where(sqlpp::value(true))
576 );
577 QwDebug << "QwDatabase::StoreDBVersion => Number of rows returned: " << record_count << QwLog::endl;
578
579 // If there is more than one run in the DB with the same run number, then there will be trouble later on. Catch and bomb out.
580 if (record_count > 1)
581 {
582 QwError << "Unable to find unique schema version in database." << QwLog::endl;
583 QwError << "Schema query returned " << record_count << " rows." << QwLog::endl;
584 QwError << "Please make sure that db_schema contains one unique." << QwLog::endl;
585 Disconnect();
586 return false;
587 }
588
589 // Run already exists in database. Pull run_id and move along.
590 if (record_count == 1)
591 {
592 auto results = QuerySelect(
593 sqlpp::select(sqlpp::all_of(db_schema))
594 .from(db_schema)
595 .where(sqlpp::value(true))
596 );
598 results,
599 [this](const auto& row) {
600 QwDebug << "QwDatabase::StoreDBVersion => db_schema_id = " << row.db_schema_id << QwLog::endl;
601 this->fVersionMajor = row.major_release_number;
602 this->fVersionMinor = row.minor_release_number;
603 this->fVersionPoint = row.point_release_number;
604 }
605 );
606 Disconnect();
607 }
608 }
609 catch (const std::exception& er)
610 {
611 QwError << er.what() << QwLog::endl;
612 Disconnect();
613 return false;
614 }
615
616 return true;
617
618}
#define NORMAL
Definition QwColor.h:65
#define BOLD
Definition QwColor.h:41
#define BLUE
Definition QwColor.h:36
#define RED
Definition QwColor.h:33
A class for handling connections to the Qweak database.
#define QwError
Predefined log drain for errors.
Definition QwLog.h:39
#define QwWarning
Predefined log drain for warnings.
Definition QwLog.h:44
#define QwMessage
Predefined log drain for regular messages.
Definition QwLog.h:49
#define QwDebug
Predefined log drain for debugging output.
Definition QwLog.h:59
QwScopedConnection & operator=(const QwScopedConnection &)=delete
bool IsConnected() const
Definition QwDatabase.cc:69
QwScopedConnection(QwDatabase *db)
Definition QwDatabase.cc:28
QwDatabase * fDatabase
Definition QwDatabase.h:85
A database interface class.
Definition QwDatabase.h:121
string fDBUsername
Name of account to connect to DB server with.
Definition QwDatabase.h:435
auto QuerySelect(const Statement &statement)
Definition QwDatabase.h:371
const string kValidVersionPoint
Definition QwDatabase.h:446
Bool_t ValidateConnection()
Checks that given connection parameters result in a valid connection.
const string GetValidVersion()
static void DefineOptions(QwOptions &options)
Defines available class options for QwOptions.
bool StoreDBVersion()
Retrieve database schema version information from database.
const string GetVersion()
void Disconnect()
Definition QwDatabase.h:313
const string kValidVersionMinor
Definition QwDatabase.h:445
Bool_t fDBInsertMissingKeys
True if missing keys should be inserted into the database automatically.
Definition QwDatabase.h:449
const string GetServerVersion()
Definition QwDatabase.h:338
string fDBServer
Name of server carrying DB to connect to.
Definition QwDatabase.h:434
Bool_t Connect()
Open a connection to the database using the predefined parameters.
string fVersionPoint
Point version number of current DB schema.
Definition QwDatabase.h:443
QwDatabase(const string &major="00", const string &minor="00", const string &point="0000")
Simple constructor.
Definition QwDatabase.cc:78
@ kQwDatabaseReadWrite
Definition QwDatabase.h:419
@ kQwDatabaseReadOnly
Definition QwDatabase.h:419
const string kValidVersionMajor
Definition QwDatabase.h:444
Bool_t fDBDebug
True if database debug information should be printed to stdout.
Definition QwDatabase.h:439
void PrintServerInfo()
virtual ~QwDatabase()
Destructor.
void SetAccessLevel(string accesslevel)
Sets the access level flag based on string labels: "off", "ro", "rw".
string fDatabase
Name of database to connect to.
Definition QwDatabase.h:433
EQwDBAccessLevel fAccessLevel
Access level of the database instance.
Definition QwDatabase.h:431
Bool_t Connected()
Get a scoped connection that automatically disconnects when destroyed.
Definition QwDatabase.h:323
DatabaseConnection fDBConnection
Definition QwDatabase.h:176
size_t QueryCount(const Statement &statement)
Definition QwDatabase.h:348
string fVersionMinor
Minor version number of current DB schema.
Definition QwDatabase.h:442
UInt_t fDBPortNumber
Port number to connect to on server (mysql default port is 3306)
Definition QwDatabase.h:437
string fVersionMajor
Major version number of current DB schema.
Definition QwDatabase.h:441
string fDBPassword
DB account password.
Definition QwDatabase.h:436
Bool_t fValidConnection
True if a valid connection was established using defined connection information.
Definition QwDatabase.h:438
EQwDBType fDBType
Type of database backend to use.
Definition QwDatabase.h:134
bool ForFirstResult(QueryResult &result, Lambda &&lambda) const
Definition QwDatabase.h:272
void ProcessOptions(QwOptions &options)
Processes the options contained in the QwOptions object.
static std::ostream & endl(std::ostream &)
End of the line.
Definition QwLog.cc:297
Command-line and configuration file options processor.
Definition QwOptions.h:141
T GetValue(const std::string &key)
Get a templated value.
Definition QwOptions.h:236
bool HasValue(const std::string &key)
Has this key been defined.
Definition QwOptions.h:229
po::options_description_easy_init AddOptions(const std::string &blockname="Specialized options")
Add an option to a named block or create new block.
Definition QwOptions.h:170