14 const char* dbname =
"mysql://host.domain/test";
15 const char* username =
"user";
16 const char* userpass =
"pass";
34 TSQLFile* f =
new TSQLFile(dbname,
"recreate", username, userpass);
35 if (f->IsZombie()) {
delete f;
return; }
39 f->SetUseSuffixes(kFALSE);
40 f->SetArrayLimit(1000);
46 TH1I* h1 =
new TH1I(
"histo1",
"histo title", 1000, -4., 4.);
47 h1->FillRandom(
"gaus",10000);
53 TList* arr =
new TList;
54 for(Int_t n=0;n<10;n++) {
55 TBox* b =
new TBox(n*10,n*100,n*20,n*200);
56 arr->Add(b, Form(
"option_%d_option",n));
58 arr->Write(
"list",TObject::kSingleKey);
61 TClonesArray clones(
"TBox",10);
63 new (clones[n]) TBox(n*10,n*100,n*20,n*200);
64 clones.Write(
"clones",TObject::kSingleKey);
74 TSQLFile* f =
new TSQLFile(dbname,
"open", username, userpass);
75 if (f->IsZombie()) {
delete f;
return; }
81 TH1* h1 = (TH1*) f->Get(
"histo");
88 TObject* obj = f->Get(
"list");
89 cout <<
"Printout of TList object" << endl;
90 if (obj!=0) obj->Print(
"*");
94 obj = f->Get(
"clones");
95 cout <<
"Printout of TClonesArray object" << endl;
96 if (obj!=0) obj->Print(
"*");
100 cout <<
"================ TBox QUERY ================ " << endl;
101 cout << f->MakeSelectQuery(TBox::Class()) << endl;
102 cout <<
"================ END of TBox QUERY ================ " << endl;
104 cout <<
"================== TH1I QUERY ================ " << endl;
105 cout << f->MakeSelectQuery(TH1I::Class()) << endl;
106 cout <<
"================ END of TH1I QUERY ================ " << endl;