ROOT
6.07/01
Reference Guide
ROOT Home Page
Main Page
Tutorials
User's Classes
Namespaces
All Classes
Files
Release Notes
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
tutorials
sql
sqlfilldb.C
Go to the documentation of this file.
1
void
sqlfilldb
(
int
nfiles = 1000)
2
{
3
// Fill run catalog with nfiles entries
4
5
const
char
*ins =
"INSERT INTO runcatalog VALUES ('%s', %d,"
6
" %d, %d, %d, %10.2f, '%s', '%s', '1997-01-15 20:16:28',"
7
" '1999-01-15 20:16:28', '%s', '%s')"
;
8
9
char
sql[4096];
10
char
dataset[32];
11
char
rawfile[128];
12
int
tag, evt = 0;
13
14
// open connection to MySQL server on localhost
15
TSQLServer
*db =
TSQLServer::Connect
(
"mysql://localhost/test"
,
"nobody"
,
""
);
16
TSQLResult
*res;
17
18
// first clean table of old entries
19
res = db->
Query
(
"DELETE FROM runcatalog"
);
20
delete
res;
21
22
// start timer
23
TStopwatch
timer
;
24
timer.
Start
();
25
26
// fill run catalog
27
for
(
int
i = 0; i < nfiles; i++) {
28
sprintf(dataset,
"testrun_%d"
, i);
29
sprintf(rawfile,
"/v1/data/lead/test/run_%d.root"
, i);
30
tag = int(
gRandom
->
Rndm
()*10.);
31
sprintf(sql, ins, dataset, i, evt, evt+10000, tag, 25.5,
"test"
,
"lead"
,
32
rawfile,
"test run dummy data"
);
33
evt += 10000;
34
res = db->
Query
(sql);
35
delete
res;
36
//printf("%s\n", sql);
37
}
38
39
delete
db;
40
41
// stop timer and print results
42
timer.
Stop
();
43
Double_t
rtime = timer.
RealTime
();
44
Double_t
ctime = timer.
CpuTime
();
45
46
printf
(
"\n%d files in run catalog\n"
, nfiles);
47
printf
(
"RealTime=%f seconds, CpuTime=%f seconds\n"
, rtime, ctime);
48
}
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:108
TStopwatch::Start
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
Definition:
TStopwatch.cxx:56
TRandom::Rndm
virtual Double_t Rndm(Int_t i=0)
Machine independent random number generator.
Definition:
TRandom.cxx:512
TSQLServer
Definition:
TSQLServer.h:45
TSQLServer::Query
virtual TSQLResult * Query(const char *sql)=0
TSQLServer::Connect
static TSQLServer * Connect(const char *db, const char *uid, const char *pw)
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:123
sqlfilldb
void sqlfilldb(int nfiles=1000)
Definition:
sqlfilldb.C:1
timer
TStopwatch timer
Definition:
pirndm.C:37
TStopwatch::Stop
void Stop()
Stop the stopwatch.
Definition:
TStopwatch.cxx:75
TSQLResult
Definition:
TSQLResult.h:34
gRandom
R__EXTERN TRandom * gRandom
Definition:
TRandom.h:62
Double_t
double Double_t
Definition:
RtypesCore.h:55
printf
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
TStopwatch
Stopwatch class.
Definition:
TStopwatch.h:30