ROOT
v6-32
Reference Guide
Loading...
Searching...
No Matches
sqlfilldb.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_sql
3
/// Fill run catalog with nfiles entries
4
///
5
/// \macro_code
6
///
7
/// \author Sergey Linev
8
9
void
sqlfilldb
(
int
nfiles = 1000)
10
{
11
const
char
*ins =
"INSERT INTO runcatalog VALUES ('%s', %d,"
12
" %d, %d, %d, %10.2f, '%s', '%s', '1997-01-15 20:16:28',"
13
" '1999-01-15 20:16:28', '%s', '%s')"
;
14
15
char
sql[4096];
16
char
dataset
[32];
17
char
rawfile[128];
18
int
tag, evt = 0;
19
20
// open connection to MySQL server on localhost
21
TSQLServer
*db =
TSQLServer::Connect
(
"mysql://localhost/test"
,
"nobody"
,
""
);
22
TSQLResult
*res;
23
24
// first clean table of old entries
25
res = db->
Query
(
"DELETE FROM runcatalog"
);
26
delete
res;
27
28
// start timer
29
TStopwatch
timer;
30
timer.
Start
();
31
32
// fill run catalog
33
for
(
int
i
= 0;
i
< nfiles;
i
++) {
34
sprintf(dataset,
"testrun_%d"
,
i
);
35
sprintf(rawfile,
"/v1/data/lead/test/run_%d.root"
,
i
);
36
tag =
int
(
gRandom
->Rndm()*10.);
37
sprintf(sql, ins, dataset,
i
, evt, evt+10000, tag, 25.5,
"test"
,
"lead"
,
38
rawfile,
"test run dummy data"
);
39
evt += 10000;
40
res = db->
Query
(sql);
41
delete
res;
42
//printf("%s\n", sql);
43
}
44
45
delete
db;
46
47
// stop timer and print results
48
timer.
Stop
();
49
Double_t
rtime = timer.
RealTime
();
50
Double_t
ctime = timer.
CpuTime
();
51
52
printf(
"\n%d files in run catalog\n"
, nfiles);
53
printf(
"RealTime=%f seconds, CpuTime=%f seconds\n"
, rtime, ctime);
54
}
Double_t
double Double_t
Definition
RtypesCore.h:59
i
Int_t i
Definition
TGraphAsymmErrors.cxx:1306
gRandom
R__EXTERN TRandom * gRandom
Definition
TRandom.h:62
TSQLResult
Definition
TSQLResult.h:31
TSQLServer
Definition
TSQLServer.h:41
TSQLServer::Query
virtual TSQLResult * Query(const char *sql)=0
TSQLServer::Connect
static TSQLServer * Connect(const char *db, const char *uid, const char *pw)
The db should be of the form: <dbms>://<host>[:<port>][/<database>], e.g.: mysql://pcroot....
Definition
TSQLServer.cxx:61
TStopwatch
Stopwatch class.
Definition
TStopwatch.h:28
TStopwatch::RealTime
Double_t RealTime()
Stop the stopwatch (if it is running) and return the realtime (in seconds) passed between the start a...
Definition
TStopwatch.cxx:110
TStopwatch::Start
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
Definition
TStopwatch.cxx:58
TStopwatch::CpuTime
Double_t CpuTime()
Stop the stopwatch (if it is running) and return the cputime (in seconds) passed between the start an...
Definition
TStopwatch.cxx:125
TStopwatch::Stop
void Stop()
Stop the stopwatch.
Definition
TStopwatch.cxx:77
int
TMVA_SOFIE_GNN_Parser.dataset
list dataset
Definition
TMVA_SOFIE_GNN_Parser.py:190
sqlfilldb
Definition
sqlfilldb.py:1
tutorials
sql
sqlfilldb.C
ROOT v6-32 - Reference Guide Generated on Tue May 19 2026 02:47:10 (GVA Time) using Doxygen 1.13.2