HARPO  5.1.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HarpoDB.cxx
Go to the documentation of this file.
1 //
2 // File HarpoDB.cxx
3 //
32 #include "HarpoDB.h"
33 #include "HarpoDebug.h"
34 #include "TSQLServer.h"
35 #include "TSQLResult.h"
36 #include "TSQLRow.h"
37 #include <TSystem.h>
38 #include <strings.h>
39 #include <stdlib.h>
40 #include <libgen.h>
41 #include <algorithm>
42 #include <iostream>
43 #include <fstream>
44 
45 using namespace std;
46 
48 
49 TSQLServer * HarpoDB::db = (TSQLServer *) NULL;
50 // HarpoDB::dbUrl = TString("mysql://127.0.0.1/harpo","reader", "ro");
51 TString HarpoDB::dbUrl = TString("mysql://llrharpo.in2p3.fr/harpo");
52 TString HarpoDB::dbuser = TString("reader");
53 TString HarpoDB::dbpw = TString("ro");
54 
55 const char *HarpoDB::GetDBName()
56 {
57  return basename((char *)dbUrl.Data());
58 }
59 
60 void HarpoDB::SetUser(TString u, TString p) {
61  dbuser = u;
62  dbpw = p;
63 }
64 
66 {
67  // list tables in database "harpo"
68  cout << "List all tables in database \"" << GetDBName()
69  << "\" on server " << db->GetHost() << endl;
70 
71  TIter next(fTables);
72  TObject* obj;
73  while ( (obj = next()) )
74  cout << "Table: " << obj->GetName() << endl;
75 }
76 
77 Bool_t HarpoDB::Open(const TString *DbUrl)
78 {
79  if(gHarpoDebug>0)
80  printf("DB %s\n",__FUNCTION__);
81 
82  if ( DbUrl != NULL ) {
83  // Url Given
84  dbUrl = *DbUrl;
85  } else {
86  const char *dburl = gSystem->Getenv("HARPO_DB_URL");
87  if ( dburl != NULL ) {
88  if ( strlen(dburl) > 0 )
89  dbUrl = TString(dburl);
90  }
91  }
92 
93  if ( dbUrl.IsNull() )
94  cout << " Warn NO Database URL" << endl;
95 
96  db = TSQLServer::Connect(dbUrl.Data(),dbuser.Data(), dbpw.Data());
97 
98  if ( db == NULL ) {
99  cout << " Error acess a database" << endl;
100  return false;
101  }
102 
103  if(gHarpoDebug>0)
104  printf("Server info: %s\n", db->ServerInfo());
105 
106  fTables = db->GetTablesList();
107 
108  return true;
109 }
110 
112 {
113  if(gHarpoDebug>0)
114  printf("DB %s\n",__FUNCTION__);
115 
116  if ( db != NULL) {
117  delete fTables;
118  delete db;
119  db = NULL;
120  fTables = NULL;
121  return true;
122  }
123  else
124  return false;
125 }
126 
127 Bool_t HarpoDB::GetTable(const TString name,HarpoDBTable &table)
128 {
129  if(gHarpoDebug>0)
130  printf("DB %s\n",__FUNCTION__);
131 
132  const char *nm = name.Data();
133  if ( fTables->FindObject(nm) == 0 ) {
134  // printf("No Table %s in DB %s\n",nm,GetDBName());
135  return false;
136  }
137  return table.Open(GetDBName(), nm);
138 }
139 
140 Bool_t HarpoDBTable::Open(const char *dbnm, const char *tbl)
141 {
142  //
143  if(gHarpoDebug>0)
144  printf("%s\n",__FUNCTION__);
145 
146  TSQLRow *row;
147  TSQLResult *res;
148 
149  TSQLServer *db = HarpoDB::GetDBServer();
150  if ( db == NULL )
151  return false; // server not opened
152 
153  res = db->GetColumns(dbnm, tbl);
154  // printf("No of field in GetColomns %d\n",res->GetFieldCount());
155  while ((row = res->Next())) {
156 
157  if ( ftypes.find(row->GetField(0)) == ftypes.end() ) {
158  ftypes[row->GetField(0)] = row->GetField(1);
159  } else {
160  // if(gHarpoDebug>0)
161  cout << "key " << row->GetField(0) << " exist" << endl;
162  }
163  delete row;
164  }
165  delete res;
166  name = tbl;
167  return true;
168 }
169 
170 Bool_t HarpoDB::ExecQuery(const TString sql,dbResults *list)
171 {
172  if(gHarpoDebug>0)
173  printf("%s\n",__FUNCTION__);
174 
175  if ( db == NULL ) return false; // server not opened
176 
177  TSQLRow *mrow;
178  TSQLResult *res = NULL;
179  if(gHarpoDebug>0)
180  cout << "SQL : " << sql << endl;
181  res = db->Query(sql.Data());
182  if ( res == NULL ) {
183  // res == NULL ==> Query error
184  return false;
185  }
186  int nrows = res->GetRowCount();
187  // cout << "nrow " << nrows << " list " << list << endl;
188  if ( (list != NULL ) && (nrows > 0)) {
189  int nfields = res->GetFieldCount();
190  while ((mrow = res->Next()) != NULL) {;
191  dbFields fields;
192  for (int j = 0; j < nfields; j++) {
193  // if (mrow->GetFieldLength(j) > 0 ) {
194  fields[res->GetFieldName(j)] =mrow->GetField(j);
195  // }
196  }
197  // cout << "map size " << fields.size() << endl;
198  list->push_back(fields);
199  delete mrow;
200  }
201  }
202  delete res;
203  return true;
204 }
205 
206 Bool_t HarpoDBTable::GetRunRow(Long_t nrun, HarpoDBRow &row )
207 {
208  if(gHarpoDebug>0)
209  printf("%s\n",__FUNCTION__);
210 
211  // Make empty run row
212  row.SetRun(nrun);
213  row.GetFields().clear();
214 
215  if ( ftypes.empty() ) {
216  printf("No table info or DB read error\n");
217  return false;
218  }
219 
220  TSQLServer *db = HarpoDB::GetDBServer();
221  if ( db == NULL )
222  return false; // server not opened
223 
224  TSQLRow *mrow;
225  TSQLResult *res = NULL;
226 
227  TString sql;
228 
229  sql += "SELECT ";
230  for (dbFields::iterator it=ftypes.begin(); it!=ftypes.end(); ++it) {
231  if ( it != ftypes.begin()) sql += ", ";
232  sql += "`" + it->first + "`";
233  }
234  sql += " FROM `" + name + "` WHERE `run` = ";
235  sql += nrun;
236  sql +=";";
237  if(gHarpoDebug>0)
238  cout << "SQL : " << sql << endl;
239 
240  // // query database and print results
241  // //if ( db->SelectDataBase("harpo") != 0 ) return rec_found;
242  res = db->Query(sql.Data());
243  if ( res == NULL ) {
244  // res == NULL ==> Query error
245  return false;
246  }
247 
248  int nrows = res->GetRowCount();
249 
250  //printf("\nGot %d rows in result\n", nrows);
251  if (nrows != 1) return false; // Bad query
252 
253  int nfields = res->GetFieldCount();
254 
255  // cout << "N Fields in" << name << " : " << nfields
256  // << endl;
257 
258  dbFields &fields = row.GetFields();
259  mrow = res->Next();
260  for (int j = 0; j < nfields; j++) {
261  if (mrow->GetFieldLength(j) > 0 ) {
262  // cout << "f " << res->GetFieldName(j) << " v " << mrow->GetField(j)
263  // << endl;
264  fields[res->GetFieldName(j)] = mrow->GetField(j);
265  // cout << "map size " << fields.size() << endl;
266  }
267  }
268  delete mrow;
269  delete res;
270  return true;
271 }
272 
273 // List Fields and values
275 {
276  if ( fields.empty() ) {
277  printf("Empty Row.\n");
278  } else {
279  for (dbFields::iterator it=fields.begin(); it!=fields.end(); ++it) {
280  cout << it->first << " = "<< it->second << endl;
281  }
282  }
283 }
284 
285 // List Fileds name and type
287 {
288  cout << " Table : " << name << "======================" << endl;
289  if ( ftypes.empty() ) {
290  printf("No table info or DB read error\n");
291  } else {
292  for (dbFields::iterator it=ftypes.begin(); it!=ftypes.end(); ++it) {
293  cout << it->first << " ("<< it->second << ")" << endl;
294  }
295  }
296 }
297 
298 //Look if filed exist in row
299 Bool_t HarpoDBRow::Lookup(const TString field)
300 {
301  return fields.find(field) != fields.end();
302 }
303 
304 //Look if filed exist in table
305 Bool_t HarpoDBTable::Lookup(const TString field)
306 {
307  return ftypes.find(field) != ftypes.end();
308 }
309 
310 // Get Value
311 Bool_t HarpoDBRow::GetVal(const TString field, TString &val)
312 {
313  dbFields::iterator it = fields.find(field);
314  if ( it != fields.end() ) {
315  val = it->second;
316  return true;
317  }
318  return false;
319 }
320 
321 //Set value for existing field
322 Bool_t HarpoDBRow::SetVal(const TString field, TString val)
323 {
324  dbFields::iterator it = fields.find(field);
325  if ( it != fields.end() ) {
326  it->second = val;
327  return true;
328  }
329  return false;
330 }
331 
332 Bool_t HarpoDBRow::SetVal(const TString field, Long_t val)
333 {
334  TString sval; sval += val;
335  return SetVal(field,sval);
336 }
337 
338 Bool_t HarpoDBRow::SetVal(const TString field, Double_t val)
339 {
340  TString sval; sval += val;
341  return SetVal(field,sval);
342 }
343 
344 // Set Map of fields types
346 {
347  fields = f;
348  for (dbFields::iterator it=fields.begin(); it!=fields.end();++it) {
349  if ( it->second.Contains("date") || it->second.Contains("time")
350  || it->second.Contains("char") )
351  { // need quote
352  it->second = ""; // replces "string" types with empy string
353  } else {
354  it->second = "0"; // replces other types with )
355  }
356  }
357 }
358 
359 // Get Filed type
360 Bool_t HarpoDBTable::GetType(const TString field, TString &type)
361 {
362  dbFields::iterator it = ftypes.find(field);
363  if ( it != ftypes.end() ) {
364  type = it->second;
365  return true;
366  }
367  return false;
368 }
369 
371 Bool_t HarpoDBTable::TypeExpression(const TString field)
372 {
373  dbFields::iterator it = ftypes.find(field);
374  if ( it != ftypes.end() ) {
375  it->second = "expression"; // not a mysql type , but will not quite
376  return true;
377  }
378  return false;
379 }
380 
381 
382 // Update DB record base on class data
383 Bool_t HarpoDBTable::DeleteRun(Long_t run)
384 {
385  if(gHarpoDebug>0)
386  printf("%s\n",__FUNCTION__);
387 
388  TSQLServer *db = HarpoDB::GetDBServer();
389  if ( db == NULL )
390  return false; // server not opened
391 
392  TString sql;
393 
394  sql += "DELETE FROM `" + name + "` WHERE `run` = " + run + ";";
395 
396  // TSQLRow *mrow;
397  TSQLResult *res = NULL;
398  res = db->Query(sql.Data());
399  if ( res == NULL ) {
400  // res == NULL ==> Query error
401  return false;
402  }
403  delete res;
404  return true;
405 }
406 
407 // Update DB record base on class data
408 Bool_t HarpoDBTable::UpdateRunRow(HarpoDBRow row,const TString option)
409 {
410  if(gHarpoDebug>0)
411  printf("%s\n",__FUNCTION__);
412 
413  if ( ftypes.empty() ) {
414  printf("No table info or DB read error\n");
415  return false;
416  }
417 
418  if ( row.GetFields().empty() ) {
419  printf("Can't update empty Row\n");
420  return false;
421  }
422 
423  Bool_t verbose = option.Contains("verbose"); // verbose show query string
424 
425  // nap::erase invalidate iterator !!!
426  dbFields &rfields = row.GetFields();
427  dbFields fields; // local copy
428  dbFields::iterator itype;
429  for (dbFields::iterator it=rfields.begin(); it!=rfields.end();++it) {
430  // cout << " Processing : " << it->first << endl;;
431  if (ftypes.find(it->first) != ftypes.end()) {
432  fields[it->first] = it->second;
433  }
434  }
435 
436  for (dbFields::iterator it=fields.begin(); it!=fields.end(); ++it) {
437  // cout << " Quoting : " << it->first << endl;;
438  if ((itype =ftypes.find(it->first)) != ftypes.end() ) {
439  if ( itype->second.Contains("date") || itype->second.Contains("time")
440  || itype->second.Contains("char") )
441  { // need quote
442  it->second.Prepend('"');
443  it->second.Append('"');
444  }
445  }
446  }
447 
448  TSQLServer *db = HarpoDB::GetDBServer();
449  if ( db == NULL )
450  return false; // server not opened
451 
452  TString sql;
453 
454  sql += "UPDATE `" + name + "` SET ";
455  for (dbFields::iterator it=fields.begin(); it!=fields.end(); ++it) {
456  if ( it->first.EqualTo("run")) continue; // skeep run field
457  if ( it != fields.begin()) sql += ", ";
458  sql += "`" + it->first + "` = " + it->second;
459  }
460  sql += " WHERE `run` = ";
461  sql += row.GetNrun();
462  sql +=";";
463  if (verbose)
464  cout << "SQL : " << sql << endl;
465 
466  TSQLResult *res;
467  res = db->Query(sql.Data());
468  if ( res == NULL ) {
469  // res == NULL ==> Query error
470  return false;
471  }
472  delete res;
473  return true;
474 }
475 
476 // Update DB record base on class data
477 Bool_t HarpoDBTable::InsertRunRow(HarpoDBRow row,const TString option)
478 {
479  if(gHarpoDebug>0)
480  printf("%s\n",__FUNCTION__);
481 
482  if ( ftypes.empty() ) {
483  printf("No table info or DB read error\n");
484  return false;
485  }
486 
487  if ( row.GetFields().empty() ) {
488  printf("Can't update empty Row\n");
489  return false;
490  }
491 
492  Bool_t verbose = option.Contains("verbose"); // verbose show query string
493  Bool_t update = option.Contains("update"); // update on duplicated key
494 
495  dbFields &rfields = row.GetFields();
496  dbFields fields; // local copy
497  dbFields::iterator itype;
498  for (dbFields::iterator it=rfields.begin(); it!=rfields.end();++it) {
499  // cout << " Processing : " << it->first << endl;;
500  if (ftypes.find(it->first) != ftypes.end()) {
501  fields[it->first] = it->second;
502  }
503  }
504 
505  for (dbFields::iterator it=fields.begin(); it!=fields.end(); ++it) {
506  // cout << " Quoting : " << it->first << endl;;
507  if ((itype =ftypes.find(it->first)) != ftypes.end() ) {
508  if ( itype->second.Contains("date") || itype->second.Contains("time")
509  || itype->second.Contains("char") )
510  { // need quote
511  it->second.Prepend('"');
512  it->second.Append('"');
513  }
514  }
515  }
516 
517  TSQLServer *db = HarpoDB::GetDBServer();
518  if ( db == NULL )
519  return false; // server not opened
520 
521  TString sql;
522  TString data;
523  TString ondup;
524 
525  sql += "INSERT INTO `" + name + "` (";
526  for (dbFields::iterator it=fields.begin(); it!=fields.end(); ++it) {
527  if ( it != fields.begin()) {
528  sql += ", ";
529  data += ", ";
530  }
531  sql += "`" + it->first + "`";
532  data += it->second;
533  if (update && (! it->first.EqualTo("run"))) {
534  if (it != fields.begin() ) ondup += ", ";
535  ondup += "`" + it->first + "`=VALUES(`" + it->first + "`)" ;
536  }
537  }
538  sql +=") VALUES (";
539  sql += data;
540  sql += ")";
541  if (update)
542  sql += " ON DUPLICATE KEY UPDATE " + ondup;
543  sql += ";";
544  if (verbose)
545  cout << "SQL : " << sql << endl;
546  TSQLResult *res;
547  res = db->Query(sql.Data());
548  if ( res == NULL ) {
549  // res == NULL ==> Query error
550  return false;
551  }
552  delete res;
553  return true;
554 }
556 // line
557 #define wl(line) \
558  fout << #line << endl;
559 // quoted lines
560 #define wq(line) \
561  fout << line << endl;
562 // line with class name
563 #define wlc(pre,class,post) \
564  fout << #pre + class + #post << endl;
565 
566 #define wqc(pre,class,post) \
567  fout << pre + class + post << endl;
568 void HarpoDBTable::MakeClass(TString cname,TString /* option */)
570 {
571  TString clname;
572  if (cname.IsNull()) {
573  clname += "HarpoDB" + name; // From Table Name
574  } else {
575  clname = cname;
576  }
577  TString cluname = clname;
578  cluname.ToUpper();
579  TString fname;
580  // LinkDef.h
581  fname = clname + "LinkDef.h";
582  cout << "Writing " << fname << endl;
583  ofstream fout;
584  fout.open(fname.Data());
585  wl(#ifdef __CINT__)
586  wl(#pragma link off all globals;)
587  wl(#pragma link off all classes;)
588  wl(#pragma link off all functions;)
589  wl()
590  wqc("#pragma link C++ class ",clname,"+;")
591  wl()
592  wl(#endif)
593  fout.close();
594 
595  //.h
596  fname = clname + ".h";
597  cout << "Writing " << fname << endl;
598  fout.open(fname.Data());
599  wqc("#ifndef ",cluname,"_H")
600  wqc("#define ",cluname,"_H")
601  wq("//////////////////////////////////////////////////////////////////////////")
602  wq("//")
603  wqc("// ",clname," (Generated by HarpoDBTable::MakeClass())")
604  wq("//")
605  wq("//////////////////////////////////////////////////////////////////////////")
606  wl(#include "TObject.h")
607  wl(#include "TString.h")
608  wl(#include "HarpoDB.h")
609  wl()
610  wqc("class ",clname," : public TObject {")
611  wl( public:)
612  wqc(" ",clname,"();")
613  wqc(" virtual ~",clname,"();")
614  wl()
615 // List of varibles
616  TString vartype;
617  for (dbFields::iterator it=ftypes.begin(); it!=ftypes.end(); ++it) {
618  if (it->second.Contains("bool") ) {
619  // vartype = "Bool_t";
620  vartype = "Long_t";
621  } else if (it->second.Contains("int") ) {
622  vartype = "Long_t";
623  } else if (it->second.Contains("dec") || it->second.Contains("float") ||
624  it->second.Contains("real") || it->second.Contains("double") ) {
625  vartype = "Double_t";
626  } else if ( it->second.Contains("date") || it->second.Contains("time")
627  || it->second.Contains("char") ) { // need quote
628  vartype = "TString";
629  } else {
630  vartype = "TString";
631  }
632  fout << " " << vartype << " " << it->first << "; // " <<
633  it->second << endl;
634  }
635  wl()
636  wq(" // Import From Raw")
637  wq(" void Import(HarpoDBRow &row);")
638  wl()
639  wq(" // Export to Raw")
640  wq(" void Export(HarpoDBRow &row);")
641  wl()
642  wq(" // Reset")
643  wq(" void Reset();")
644  wl()
645  wq(" // Print")
646  wq(" void print();")
647  wl()
648  wl( protected:)
649  wl()
650  wl( private:)
651  wl()
652  wqc("ClassDef(",clname,",1) //! ROOT CINT declaration")
653  wl(};)
654  wl()
655  wl()
656  wqc("#endif // ",cluname,"_H")
657  wq("// Local Variables:")
658  wq("// mode: c++")
659  wq("// End:")
660  fout.close();
661 
662  // .cxx
663  fname = clname + ".cxx";
664  cout << "Writing " << fname << endl;
665  fout.open(fname.Data());
666  wq("//////////////////////////////////////////////////////////////////////////")
667  wq("//")
668  wqc("
669  wq("//")
670  wqc("
671  wq("//")
672  wq("
673  wl()
674  wqc("#include \"",clname,".h\"")
675  wl(#include <iostream>)
676  wl()
677  wqc("ClassImp(",clname,")")
678  wl()
679  wq("// Constructor")
680  wqc("",clname + "::" + clname,"()")
681  wl({)
682  wq(" // Empy default constructor for ROOT IO")
683  wl(})
684  wl()
685  wq("// Distructor")
686  wqc("",clname + "::~" + clname,"()")
687  wl({)
688  wq(" //...")
689  wl(})
690  wl()
691  wq("// Import From Row")
692  wqc("void ",clname,"::Import(HarpoDBRow &row)")
693  wl({)
694  // Import function
695  wq(" TString var;")
696  TString func;
697  for (dbFields::iterator it=ftypes.begin(); it!=ftypes.end(); ++it) {
698  if (it->second.Contains("bool") ) {
699  func = ".Atoll();";
700  } else if (it->second.Contains("int") ) {
701  func = ".Atoll();";
702  } else if (it->second.Contains("dec") || it->second.Contains("float") ||
703  it->second.Contains("real") || it->second.Contains("double") ) {
704  func = ".Atof();";
705  } else if ( it->second.Contains("date") || it->second.Contains("time")
706  || it->second.Contains("char") ) { // need quote
707  func = ";";
708  } else {
709  func = ";";
710  }
711  fout << " if (row.GetVal(" << '"' << it->first << '"' << ",var))" << endl;
712  fout << " " << it->first << " = var" << func << endl;
713  }
714  wl(})
715  wl()
716  wq("// Export to Row")
717  wqc("void ",clname,"::Export(HarpoDBRow &row)")
718  wl({)
719  // Import function
720  for (dbFields::iterator it=ftypes.begin(); it!=ftypes.end(); ++it) {
721  fout << " if (row.Lookup(" << '"' << it->first << '"' << "))" << endl;
722  fout << " row.SetVal(" << '"' << it->first << '"' <<
723  ", "<< it->first << ");"<< endl;
724  }
725  wl(})
726  wl()
727  wq("// Reset to zero values")
728  wqc("void ",clname,"::Reset()")
729  wl({)
730  TString def;
731  for (dbFields::iterator it=ftypes.begin(); it!=ftypes.end(); ++it) {
732  if (it->second.Contains("bool") ) {
733  def = "false";
734  } else if (it->second.Contains("int") ) {
735  def = "0";
736  } else if (it->second.Contains("dec") || it->second.Contains("float") ||
737  it->second.Contains("real") || it->second.Contains("double") ) {
738  def = "0.0";
739  } else if ( it->second.Contains("date") || it->second.Contains("time")
740  || it->second.Contains("char") ) { // need quote
741  def = "TString()";
742  } else {
743  def = "TString()";
744  }
745  fout << " " << it->first << " = " << def << ";"<< endl;
746  }
747  wl(})
748  wl()
749  wq("// Print")
750  wqc("void ",clname,"::print()")
751  wl({)
752  for (dbFields::iterator it=ftypes.begin(); it!=ftypes.end(); ++it) {
753  fout << " std::cout << ";
754  fout << "\"" << it->first << " = \" << " << it->first ;
755  fout << " << std::endl;" << endl;
756  }
757  wl(})
758  wl()
759  wqc("// EOF ",clname,".cxx")
760  fout.close();
761 
762 }
763 //EoF
Bool_t Open(const char *dbnm, const char *tbl)
Definition: HarpoDB.cxx:140
Bool_t UpdateRunRow(HarpoDBRow row, const TString option="")
Definition: HarpoDB.cxx:408
Bool_t GetRunRow(Long_t nrun, HarpoDBRow &row)
Query Table for given run information.
Definition: HarpoDB.cxx:206
static TSQLServer * db
Definition: HarpoDB.h:137
static void SetUser(TString u, TString p)
Definition: HarpoDB.cxx:60
Bool_t Lookup(const TString field)
Lookup filed exist.
Definition: HarpoDB.cxx:305
void list()
Definition: HarpoDB.cxx:65
Bool_t Open(const TString *DbUrl=NULL)
Definition: HarpoDB.cxx:77
static const char * GetDBName()
Definition: HarpoDB.cxx:55
std::list< dbFields > dbResults
Definition: HarpoDB.h:21
void list()
Definition: HarpoDB.cxx:286
Long_t GetNrun()
Get method for run number of this record.
Definition: HarpoDB.h:53
static TSQLServer * GetDBServer()
Definition: HarpoDB.h:133
Bool_t GetTable(const TString name, HarpoDBTable *table)
Definition: HarpoDB.h:122
Bool_t InsertRunRow(HarpoDBRow row, const TString option="")
Definition: HarpoDB.cxx:477
#define wq(line)
Definition: HarpoDB.cxx:560
Bool_t SetVal(const TString field, TString val)
Definition: HarpoDB.cxx:322
Bool_t DeleteRun(Long_t run)
Delete run from table.
Definition: HarpoDB.cxx:383
#define wqc(pre, class, post)
Definition: HarpoDB.cxx:566
Bool_t Lookup(const TString field)
Lookup filed exist.
Definition: HarpoDB.cxx:299
Bool_t GetVal(const TString field, TString &val)
Return value of existing field in Tstring.
Definition: HarpoDB.cxx:311
Bool_t TypeExpression(const TString field)
Mark filed as expression for insert and update.
Definition: HarpoDB.cxx:371
static int type
fname
Definition: HarpoDB.cxx:663
static TString dbUrl
Definition: HarpoDB.h:138
#define wl(line)
Definition: HarpoDB.cxx:557
void SetRun(Long_t r)
Definition: HarpoDB.h:54
Bool_t ExecQuery(const TString sql, dbResults *list=NULL)
Definition: HarpoDB.cxx:170
Long64_t gHarpoDebug
Definition: HarpoDebug.cxx:9
dbFields & GetFields()
Definition: HarpoDB.h:45
unsigned int res
Definition: Pmm2Status.h:428
static TString dbuser
Definition: HarpoDB.h:139
static TString dbpw
Definition: HarpoDB.h:140
void list()
list all fields with values
Definition: HarpoDB.cxx:274
std::map< TString, TString > dbFields
Definition: HarpoDB.h:16
Bool_t GetType(const TString field, TString &type)
Return Type of field in TString.
Definition: HarpoDB.cxx:360
Bool_t Close()
Definition: HarpoDB.cxx:111
void SetFields(dbFields f)
Definition: HarpoDB.cxx:345
void MakeClass(TString cname, TString option="")
Definition: HarpoDB.cxx:569