ROOT
Version v6.34
master
v6.36
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.py
Go to the documentation of this file.
1
## \file
2
## \ingroup tutorial_sql
3
## \notebook -nodraw
4
## Fill run catalog with nfiles entries
5
##
6
## Based on sqlfill.C by Sergey Linev
7
##
8
## \macro_code
9
##
10
## \author Juan Fernando Jaramillo Botero
11
12
from
ROOT
import
TSQLServer, TSQLResult, TStopwatch, gRandom
13
14
15
nfiles = 1000
16
17
ins =
"INSERT INTO runcatalog VALUES ('%s', %d,"
\
18
" %d, %d, %d, %10.2f, '%s', '%s', '1997-01-15 20:16:28',"
\
19
" '1999-01-15 20:16:28', '%s', '%s')"
20
21
tag = evt = 0
22
23
# open connection to MySQL server on localhost
24
db =
TSQLServer.Connect
(
"mysql://localhost/test"
,
"nobody"
,
""
)
25
26
# first clean table of old entries
27
res =
db.Query
(
"DELETE FROM runcatalog"
)
28
29
# start timer
30
timer =
TStopwatch
()
31
timer.Start
()
32
33
# fill run catalog
34
for
i
in
range
(nfiles):
35
dataset =
"testrun_%d"
% i
36
rawfile =
"/v1/data/lead/test/run_%d.root"
% i
37
tag =
int
(
gRandom.Rndm
() * 10.)
38
sql = ins % (dataset, i, evt, evt + 10000, tag, 25.5,
"test"
,
"lead"
,
39
rawfile,
"test run dummy data"
)
40
evt += 10000
41
res =
db.Query
(sql)
42
# print("%s" % sql)
43
44
45
# stop timer and print results
46
timer.Stop
()
47
rtime =
timer.RealTime
()
48
ctime =
timer.CpuTime
()
49
50
print(
""
)
51
print(
"%d files in run catalog"
% nfiles)
52
print(
"RealTime=%f seconds, CpuTime=%f seconds"
% (rtime, ctime))
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
TStopwatch
Stopwatch class.
Definition
TStopwatch.h:28
int
tutorials
sql
sqlfilldb.py
ROOT v6-34 - Reference Guide Generated on Sun Apr 27 2025 15:40:21 (GVA Time) using Doxygen 1.10.0