17 void table_reupload(
const char* fDbName =
"Geometry_fms",
const char* fTableName =
"fmsChannelGeometry",
const char* fFlavorName =
"ofl",
18 const char* fRequestTimestamp =
"2014-02-22 00:00:00",
19 const char* fStoreTimestamp =
"2014-12-20 00:00:00" ) {
28 if (!fDbName || !fTableName || !fFlavorName || !fRequestTimestamp || ! fStoreTimestamp) {
29 std::cerr <<
"ERROR: Missing initialization data, please check input parameters!\n";
33 gSystem->Setenv(
"DB_ACCESS_MODE",
"write");
36 gROOT->Macro(
"LoadLogger.C");
37 gSystem->Load(
"St_base.so");
38 gSystem->Load(
"libStDb_Tables.so");
39 gSystem->Load(
"StDbLib.so");
45 StDbTable* dbtable = node->addDbTable(fTableName);
46 dbtable->setFlavor(fFlavorName);
49 mgr->setRequestTime(fRequestTimestamp);
50 mgr->fetchDbTable(dbtable);
53 std::cout <<
"READ CHECK: " << dbtable->printCstructName() <<
" has data: " << (dbtable->hasData() ?
"yes" :
"no") <<
" (" << dbtable->GetNRows() <<
" rows)" << std::endl;
55 if (!dbtable->hasData()) {
56 std::cout <<
"ERROR: This table has no data to reupload. Please try some other timestamp!";
62 std::cout <<
"ATTENTION: please confirm that you want to reupload " << fDbName <<
" / " << fTableName <<
", " << fRequestTimestamp <<
" data with " << fStoreTimestamp <<
" timestamp.\n Type YES to proceed: ";
63 std::cin.getline(confirm,256);
65 if (test_cnf !=
"YES") {
66 std::cout <<
"since you've typed \"" << test_cnf <<
"\" and not \"YES\", data won't be reuploaded." << std::endl;
71 if (dbtable->hasData()) {
72 mgr->setStoreTime(fStoreTimestamp);
73 if (mgr->storeDbTable(dbtable)) {
74 std::cout <<
"SUCCESS: Data reupload complete for " << fDbName <<
" / " << fTableName <<
" [ flavor : " << fFlavorName <<
" ]"
75 <<
"\n" <<
"Data copied FROM " << fRequestTimestamp <<
" TO " << fStoreTimestamp << std::endl << std::endl;
77 std::cerr <<
"ERROR: Something went wrong. Please send error message text to DB Admin!" << std::endl;
static StDbManager * Instance()
strdup(..) is not ANSI