ROOT
master
Reference Guide
Loading...
Searching...
No Matches
SQLiteVersionsOfRoot.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_sql
3
/// \notebook -js
4
/// This tutorial demonstrates how TSQLServer can be used to create a connection with a SQlite3 database.
5
/// It accesses the Sqlite data base.
6
/// Download from https://root.cern/files/root_download_stats.sqlite
7
/// Then a TH1F histogram is created and filled
8
/// using a expression which receives the recorded
9
/// values in the "version" column of the sqlite3 database.
10
/// The histogram shows the usage of the ROOT development version.
11
/// This product includes GeoLite2 data created by MaxMind, available from
12
/// <a href="http://www.maxmind.com">http://www.maxmind.com</a>.
13
///
14
/// \macro_code
15
///
16
/// \author Alexandra-Maria Dobrescu 08/2018
17
18
#include <
TSQLiteServer.h
>
19
#include <
TSQLiteResult.h
>
20
#include <
TSQLRow.h
>
21
#include <
TString.h
>
22
23
void
SQLiteVersionsOfRoot
(){
24
25
TSQLServer
*
db
=
TSQLServer::Connect
(
"sqlite://root_download_stats.sqlite"
,
""
,
""
);
26
27
const
char
*
rootSourceVersion
=
"SELECT Version FROM accesslog;"
;
28
29
TSQLResult
*
rootSourceVersionRes
=
db
->Query(
rootSourceVersion
);
30
31
TH1F
*
hVersionOfRoot
=
new
TH1F
(
"hVersionOfRoot"
,
"Development Versions of ROOT"
, 7, 0, -1);
32
33
while
(
TSQLRow
*row =
rootSourceVersionRes
->Next()) {
34
TString
rowVersion
(row->GetField(0));
35
TString
shortVersion
(
rowVersion
(0,4));
36
hVersionOfRoot
->Fill(
shortVersion
,1);
37
delete
row;
38
}
39
40
TCanvas
*
VersionOfRootHistogram
=
new
TCanvas
();
41
42
hVersionOfRoot
->GetXaxis()->LabelsOption(
"a"
);
43
hVersionOfRoot
->LabelsDeflate(
"X"
);
44
hVersionOfRoot
->Draw();
45
}
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
TSQLRow.h
TSQLiteResult.h
TSQLiteServer.h
TString.h
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
TCanvas
The Canvas class.
Definition
TCanvas.h:23
TH1F
1-D histogram with a float per channel (see TH1 documentation)
Definition
TH1.h:645
TSQLResult
Definition
TSQLResult.h:31
TSQLRow
Definition
TSQLRow.h:30
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
TString
Basic string class.
Definition
TString.h:139
tutorials
io
sql
SQLiteVersionsOfRoot.C
ROOT master - Reference Guide Generated on Fri Jan 24 2025 04:37:19 (GVA Time) using Doxygen 1.10.0