StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Db_PrintTable.C
1 class St_db_Maker;
2 St_db_Maker *dbMk = 0;
3 class TTable;
4 TTable *table = 0;
5 //________________________________________________________________________________
6 void Load() {
7  if (gClassTable->GetID("StDbManager") < 0) {
8  // Baseline shared libraries
9  gSystem->Load("libTable");
10  gSystem->Load("St_base");
11  gSystem->Load("StChain");
12  gSystem->Load("StUtilities");
13  // DB-specific libs
14  // may only need libStDb_Tables.so
15  // but may need St_Tables.so... so I'm using this one
16  // gSystem->Load("libStDb_Tables.so");
17  gSystem->Load("St_Tables.so");
18  gSystem->Load("StDbLib.so");
19  gSystem->Load("StDbBroker.so");
20  gSystem->Load("St_db_Maker.so");
21  }
22  dbMk = new St_db_Maker("db","MySQL:StarDb");//,"$STAR/StarDb","$PWD/StarDb");
23  dbMk->SetDebug(1);
24  //dbMk->SetFlavor("ofl");
25  dbMk->Init();
26 }
27 //________________________________________________________________________________
28 void Db_PrintTable(const Char_t *tabNam = "Calibrations/ftpc/ftpcCoordTrans",
29  Int_t date = 20040227,
30  Int_t time = 1){
31 fprintf(stderr," 0. cout = %x \n", (void*)cout);
32  if (dbMk == 0) Load();
33  dbMk->SetDateTime(date,time);
34  fprintf(stderr," 1. cout = %x \n",(void*) cout);
35 #if 0
36  // to browse many databases, use this approach
37  const char* dbs[] = {"Geometry","Calibrations","RunLog","Conditions",0};
38  for(int i=0;dbs[i]!=0;i++)dbMk->GetDataBase(dbs[i]);
39 #else
40  // to browse 1 database, use this one
41  TDataSet *set = dbMk->GetDataBase(gSystem->DirName(tabNam));
42  table = (TTable *) set->Find(gSystem->BaseName(tabNam));
43  if (table) {
44  TDatime t[2];
45  dbMk->GetValidity(table,t);
46  cout << "Validity:" << t[0].GetDate() << "/" << t[0].GetTime()
47  << " ----- " << t[1].GetDate() << "/" << t[1].GetTime() << endl;
48  Int_t Nrows = table->GetNRows();
49  if (Nrows > 10) Nrows = 10;
50  table->Print(0,Nrows);
51 #if 0
52  TString name(gSystem->BaseName(tabNam));
53  name += Form(".%06i.%06i.root",t[0].GetDate(),t[0].GetTime());
54  TFile *f = new TFile(name.Data(),"RECREATE");
55  table->Write();
56  delete f;
57 #endif
58  }
59  else cout << "Table:" << tabNam << " has not been found" << endl;
60 #endif
61  fprintf(stderr," 2. cout = %x \n",(void*) cout);
62  // TBrowser* b2 = new TBrowser("TestDbMaker",dbMk);
63 
64 }
65 
66 
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Definition: TDataSet.cxx:893
virtual Long_t GetNRows() const
Returns the number of the used rows for the wrapped table.
Definition: TTable.cxx:1388
Definition: TTable.h:48
virtual Char_t * Print(Char_t *buf, Int_t n) const
Create IDL table defintion (to be used for XDF I/O)
Definition: TTable.cxx:1548
virtual TDataSet * Find(const char *path) const
Definition: TDataSet.cxx:362