ROOT
6.30.04
Reference Guide
All
Namespaces
Files
Pages
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))
tutorials
sql
sqlfilldb.py
Generated on Tue May 5 2020 14:03:50 for ROOT by
1.8.5