This is an example illustrating how the TSQLFile class can be used.
Histogram, list of TBox and clones array of TBox objects are stored to TSQLFile and read back. Except for the specific TSQLFile configuration, the TSQLFile functionality is absolutely similar to a normal root TFile
const char* dbname = "mysql://host.domain/test";
const char* username = "user";
const char* userpass = "pass";
void sqltables()
{
tables_write();
tables_read();
}
void tables_write()
{
TH1I* h1 =
new TH1I(
"histo1",
"histo title", 1000, -4., 4.);
for(
Int_t n=0;n<10;n++) {
TBox* b =
new TBox(n*10,n*100,n*20,n*200);
arr->
Add(b,
Form(
"option_%d_option",n));
}
for(int n=0;n<10;n++)
new (clones[n])
TBox(n*10,n*100,n*20,n*200);
}
void tables_read()
{
if (h1!=0) {
}
cout << "Printout of TList object" << endl;
if (obj!=0) obj->
Print(
"*");
delete obj;
cout << "Printout of TClonesArray object" << endl;
if (obj!=0) obj->
Print(
"*");
delete obj;
cout << "================ TBox QUERY ================ " << endl;
cout << "================ END of TBox QUERY ================ " << endl;
cout << "================== TH1I QUERY ================ " << endl;
cout << "================ END of TH1I QUERY ================ " << endl;
}
- Author
- Sergey Linev
Definition in file sqltables.C.