Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
SQLitePlatformDistribution.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/// In order to display the Platform Distribution of ROOT, we choose to create two TH1F
8/// histograms: one that includes all types of platforms, other filtering and classifying them.
9/// This procedure is taking as parameter the values stored in the "Platform" column from the
10/// database. At the end, the histograms are filled
11/// with their specific demand regarding the platform's type.
12/// This product includes GeoLite2 data created by MaxMind, available from
13/// <a href="http://www.maxmind.com">http://www.maxmind.com</a>.
14///
15/// \macro_code
16///
17/// \author Alexandra-Maria Dobrescu 08/2018
18
19#include <TSQLiteServer.h>
20#include <TSQLiteResult.h>
21#include <TSQLRow.h>
22#include <TString.h>
23
25
26 TSQLServer *db = TSQLServer::Connect("sqlite://root_download_stats.sqlite", "", "");
27
28 const char *rootPlatform = "SELECT Platform FROM accesslog;";
29
31
32 TH1F *hrootPlatform = new TH1F("hrootPlatform", "Platform Distribution", 7, 0, -1);
33 TH1F *shorthrootPlatform = new TH1F("shorthrootPlatform", "Short Platform Distribution", 7, 0, -1);
34
35 while (TSQLRow *row = rootPlatformRes->Next()) {
36 TString rowPlatform(row->GetField(0));
41 if ( rowPlatform.Contains("win32") ){
43 } else if ( rowPlatform.Contains("Linux") ){
45 } else if ( rowPlatform.Contains("source") ){
47 } else if ( rowPlatform.Contains("macosx64") ){
49 } else if ( rowPlatform.Contains("IRIX64") ){
51 }
52
53 hrootPlatform->Fill(Platform,1);
54
55 delete row;
56 }
57
59
60 hrootPlatform->GetXaxis()->LabelsOption("a");
61 hrootPlatform->LabelsDeflate("X");
62 hrootPlatform->Draw();
63
65
66 shorthrootPlatform->GetXaxis()->LabelsOption("a");
67 shorthrootPlatform->LabelsDeflate("X");
68 shorthrootPlatform->Draw();
69}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
The Canvas class.
Definition TCanvas.h:23
1-D histogram with a float per channel (see TH1 documentation)
Definition TH1.h:622
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....
Basic string class.
Definition TString.h:139