ROOT
Version v6.34
master
v6.32
v6.30
v6.28
v6.26
v6.24
v6.22
v6.20
v6.18
v6.16
v6.14
v6.12
v6.10
v6.08
v6.06
Reference Guide
►
ROOT
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
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
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
gRandom
R__EXTERN TRandom * gRandom
Definition
TRandom.h:62
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
TRandom::Rndm
Double_t Rndm() override
Machine independent random number generator.
Definition
TRandom.cxx:559
TSQLResult
Definition
TSQLResult.h:31
TSQLServer
Definition
TSQLServer.h:41
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
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-34 - Reference Guide Generated on Mon Apr 14 2025 05:29:48 (GVA Time) using Doxygen 1.10.0