Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
SQLitePlatformDistribution.C File Reference

Detailed Description

View in nbviewer Open in SWAN
This tutorial demonstrates how TSQLServer can be used to create a connection with a SQlite3 database.

It accesses the Sqlite data base. Download from https://root.cern/files/root_download_stats.sqlite In order to display the Platform Distribution of ROOT, we choose to create two TH1F histograms: one that includes all types of platforms, other filtering and classifying them. This procedure is taking as parameter the values stored in the "Platform" column from the database. At the end, the histograms are filled with their specific demand regarding the platform's type. This product includes GeoLite2 data created by MaxMind, available from http://www.maxmind.com.

#include <TSQLiteServer.h>
#include <TSQLiteResult.h>
#include <TSQLRow.h>
#include <TString.h>
TSQLServer *db = TSQLServer::Connect("sqlite://root_download_stats.sqlite", "", "");
const char *rootPlatform = "SELECT Platform FROM accesslog;";
TH1F *hrootPlatform = new TH1F("hrootPlatform", "Platform Distribution", 7, 0, -1);
TH1F *shorthrootPlatform = new TH1F("shorthrootPlatform", "Short Platform Distribution", 7, 0, -1);
while (TSQLRow *row = rootPlatformRes->Next()) {
TString rowPlatform(row->GetField(0));
if ( rowPlatform.Contains("win32") ){
} else if ( rowPlatform.Contains("Linux") ){
} else if ( rowPlatform.Contains("source") ){
} else if ( rowPlatform.Contains("macosx64") ){
} else if ( rowPlatform.Contains("IRIX64") ){
}
delete row;
}
hrootPlatform->GetXaxis()->LabelsOption("a");
hrootPlatform->LabelsDeflate("X");
hrootPlatform->Draw();
shorthrootPlatform->GetXaxis()->LabelsOption("a");
shorthrootPlatform->LabelsDeflate("X");
}
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:645
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
Author
Alexandra-Maria Dobrescu 08/2018

Definition in file SQLitePlatformDistribution.C.