Namespaces | Classes | Typedefs | Functions
cet::sqlite Namespace Reference

Namespaces

 detail
 
 errors
 
 ExceptionDetail
 

Classes

struct  column
 
struct  column< double, Constraints... >
 
struct  column< float, Constraints... >
 
struct  column< int, Constraints... >
 
struct  column< long long, Constraints... >
 
struct  column< long, Constraints... >
 
struct  column< std::string, Constraints... >
 
struct  column< unsigned int, Constraints... >
 
struct  column< unsigned long long, Constraints... >
 
struct  column< unsigned long, Constraints... >
 
class  column_base
 
class  Connection
 
class  ConnectionFactory
 
struct  IncompleteInsert
 
struct  IncompleteSelectStmt
 
class  Ntuple
 
struct  permissive_column
 
struct  permissive_column< column< T, Constraints... > >
 
struct  primary_key
 
struct  query_result
 
struct  SelectStmt
 
class  Transaction
 

Typedefs

template<size_t N>
using name_array = std::array< std::string, N >
 
using Exception = cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate >
 

Functions

template<typename... Cols>
void create_table (sqlite3 *const db, std::string const &tablename, Cols const &...cols)
 
void create_table_as (std::string const &tablename, SelectStmt const &stmt)
 
void exec (sqlite3 *db, std::string const &ddl)
 
std::string assembleNoLockURI (std::string const &filename)
 
bool hasTableWithSchema (sqlite3 *db, std::string const &tablename, std::string expectedSchema)
 
unsigned nrows (sqlite3 *db, std::string const &tablename)
 
void delete_from (sqlite3 *db, std::string const &tablename)
 
void drop_table (sqlite3 *db, std::string const &tablename)
 
void drop_table_if_exists (sqlite3 *db, std::string const &tablename)
 
template<typename... Args>
void createTableIfNeeded (sqlite3 *db, bool const delete_contents, std::string const &tablename, permissive_column< Args > const &...cols)
 
auto insert_into (sqlite3 *const db, std::string const &tablename)
 
template<typename T >
T unique_value (query_result< T > const &r)
 
template<typename... Args>
std::ostream & operator<< (std::ostream &os, query_result< Args... > const &res)
 
template<typename... Args>
query_result< Args... > query (sqlite3 *db, std::string const &ddl)
 
template<typename... T>
auto select (T const &...t)
 
template<typename... T>
auto select_distinct (T const &...t)
 
template<typename... Args>
void operator<< (query_result< Args... > &r, SelectStmt const &cq)
 
template<typename T = double>
T min (sqlite3 *const db, std::string const &table_name, std::string const &column_name)
 
template<typename T = double>
T max (sqlite3 *const db, std::string const &table_name, std::string const &column_name)
 
double mean (sqlite3 *db, std::string const &table_name, std::string const &column_name)
 
double median (sqlite3 *db, std::string const &table_name, std::string const &column_name)
 
double rms (sqlite3 *db, std::string const &table_name, std::string const &column_name)
 

Typedef Documentation

Definition at line 33 of file Exception.h.

template<size_t N>
using cet::sqlite::name_array = typedef std::array<std::string, N>

Definition at line 42 of file column.h.

Function Documentation

std::string cet::sqlite::assembleNoLockURI ( std::string const &  filename)
template<typename... Cols>
void cet::sqlite::create_table ( sqlite3 *const  db,
std::string const &  tablename,
Cols const &...  cols 
)

Definition at line 156 of file create_table.h.

References cet::sqlite::detail::create_table_ddl(), and exec().

159  {
160  auto const& ddl = detail::create_table_ddl(tablename, cols...);
161  sqlite::exec(db, ddl);
162  }
const int cols[3]
std::string create_table_ddl(std::string const &tablename, Cols const &...cols)
Definition: create_table.h:134
void exec(sqlite3 *db, std::string const &ddl)
void cet::sqlite::create_table_as ( std::string const &  tablename,
SelectStmt const &  stmt 
)
inline

Definition at line 165 of file create_table.h.

References cet::sqlite::detail::create_table_as_ddl(), cet::sqlite::SelectStmt::db_, and exec().

Referenced by art::TimeTracker::postEndJob().

166  {
168  sqlite::exec(stmt.db_, ddl);
169  }
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
void exec(sqlite3 *db, std::string const &ddl)
std::string create_table_as_ddl(std::string const &tablename, SelectStmt const &stmt)
Definition: create_table.h:144
template<typename... Args>
void cet::sqlite::createTableIfNeeded ( sqlite3 *  db,
bool const  delete_contents,
std::string const &  tablename,
permissive_column< Args > const &...  cols 
)

Definition at line 49 of file helpers.h.

References cet::sqlite::detail::create_table_ddl(), delete_from(), exec(), and hasTableWithSchema().

Referenced by cet::sqlite::Ntuple< Args >::Ntuple().

53 {
54  auto const& sqlddl = detail::create_table_ddl(tablename, cols...);
55  if (hasTableWithSchema(db, tablename, sqlddl)) {
56  if (delete_contents) {
57  delete_from(db, tablename); // Prefer drop_table, but failure-to-prepare
58  // exception ends up being thrown.
59  }
60  } else {
61  exec(db, sqlddl);
62  }
63 }
bool hasTableWithSchema(sqlite3 *db, std::string const &tablename, std::string expectedSchema)
void delete_from(sqlite3 *db, std::string const &tablename)
const int cols[3]
std::string create_table_ddl(std::string const &tablename, Cols const &...cols)
Definition: create_table.h:134
void exec(sqlite3 *db, std::string const &ddl)
void cet::sqlite::delete_from ( sqlite3 *  db,
std::string const &  tablename 
)

Referenced by createTableIfNeeded().

void cet::sqlite::drop_table ( sqlite3 *  db,
std::string const &  tablename 
)
void cet::sqlite::drop_table_if_exists ( sqlite3 *  db,
std::string const &  tablename 
)
void cet::sqlite::exec ( sqlite3 *  db,
std::string const &  ddl 
)
bool cet::sqlite::hasTableWithSchema ( sqlite3 *  db,
std::string const &  tablename,
std::string  expectedSchema 
)

Referenced by createTableIfNeeded().

auto cet::sqlite::insert_into ( sqlite3 *const  db,
std::string const &  tablename 
)
inline

Definition at line 112 of file insert.h.

References febshutoff_auto::db, and fillBadChanDBTables::result.

113  {
114  std::string result{"insert into " + tablename};
115  return IncompleteInsert{db, std::move(result)};
116  }
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
template<typename T = double>
T cet::sqlite::max ( sqlite3 *const  db,
std::string const &  table_name,
std::string const &  column_name 
)

Definition at line 68 of file statistics.h.

References r(), select(), and unique_value().

Referenced by ana::CutOptimization::AbsUncertainty(), stan::variational::advi< stan_model, stan::variational::normal_meanfield, rng_t >::adapt_eta(), genie::flux::GCylindTH1Flux::AddEnergySpectrum(), ana::AddErrorInQuadrature(), generic.views.Pages.ComparisonTablePage::AddTable(), AddUpDwUncerts(), AddUpDwUncerts2D(), adjustspeed(), adjusttick(), genie::GRV98LO::AllPDFs(), ana::AlmostEqual(), zcl::SMMTriggerAna::analyze(), mono::DataCheckMonopole::analyze(), zcl::FmmTriggerAna::analyze(), zcl::FmmTrackerAna::analyze(), zcl::FmmTrackerValidation::analyze(), beamlinereco::EventWaveformDump::analyze(), mono::Monopole::analyze(), zcl::FastMMStudy::analyze(), ddt::SuperDDTEva::analyze(), slid::LIDTraining::analyze(), trk::CosmicTrackAna::analyze(), AnaPlotMaker(), APDPlots(), novaddt::HotMapMaker::AppendHot(), rsim::FPGA_DualCorrelatedSampling::ASICToDigits(), rsim::FPGA_MatchedFiltering::ASICToDigits(), auto_legend(), evd::TZProjPad::AutoZoomHelper(), evdb::Colors::Background(), calib::DCMTimingOffset::beginJob(), evgen::TextFileGen::beginJob(), chaninfo::CosmicEff::beginRun(), calib::DriftResponseCalc::beginRun(), calib::StopperThreshold::beginRun(), calib::DCMTimingOffset::beginRun(), bin_composition_pie_chart(), BinSigma(), ana::Multiverse::BinSigma(), ana::GenieMultiverseSpectra::BinSigma(), caf::BlindThisSlice(), evd::TQPad::BookHistogram(), genie::GMCJDriver::BootstrapXSecSplineSummation(), jmshower::RecoJMShower::CalcANN(), cheat::BackTracker::CalcDaughterEscapingEnergy(), CalcRWithSysts(), CalcRWithSystsNus17(), cheat::BackTracker::CalcTotalEscapingEnergy(), genie::SKKinematicsGenerator::CalculateKin_AtharSingleKaon(), genie::COHKinematicsGenerator::CalculateKin_ReinSehgal(), calculateWrongSignNue(), calculateWrongSignNumuQ1(), calculateWrongSignNumuQ2(), calculateWrongSignNumuQ3(), calculateWrongSignNumuQ4(), geo::GeometryBase::CellId(), stan::math::cholesky_block::chain(), stan::math::check_consistent_sizes(), stan::math::cholesky_block::cholesky_block(), stan::math::choose(), ana::IConstrainedFitVar::Clamp(), lem::Clamp(), geo::ClampRayToDetectorVolume(), trk::CosmicTrackSelection::CleanSample(), genie::utils::kinematics::CohQ2Lim(), art::detail::columnWidth(), ana::CombineExposures(), compare_cos_numi(), ana::ComparePredictions(), ana::PredictionInterp::ComponentDerivative(), ComputeErrors(), cmf::ContourMaker::ContourMaker(), genie::utils::CosTheta0Max(), geo::GeometryBase::CountCellsOnLineFast(), ana::CountingExperimentPValue(), ana::CountingExperimentPValueByLL(), trk::KalmanGeoHelper::CountMissedCellsOnLine(), rsim::LegacyPulseShaper::CreateTrace(), Plotter::DataMCComparison(), ViewHighcharts::dataToSeries(), DCMOffsetCalculator(), genie::mueloss::KokoulinPetrukhinModel::dE_dx(), demoFitContours(), geo::LiveGeometry::DistToBack(), red::EWCosmics::distToBorder(), geo::LiveGeometry::DistToClosestBadRegion(), plot_xsec_1d::do_focusing_1bin(), plot_xsec_1d::do_multiverse_1bin(), plot_xsec_1d::do_up_down_1bin(), ana::GenericSystComponentScale< T >::DoShift(), dt::DiscreteTracker::DotScore(), lem::Potential::Downsampled(), dozooming(), Canvas.Canvas::draw(), generic.tools.ImageMaker.ImageMaker::draw(), DrawAxes(), fnex::CorrectedSpectrum::DrawCounts(), fnex::CorrectedSpectrum::DrawDataVsMC(), drawHistograms(), DrawUtils::DrawPlotStack(), fnex::CorrectedSpectrum::DrawStacks(), ana::TwoSampleDecomp::DrawTwoSamplesWithRatios(), ValidCalibPDF::DriftTex(), EHadVisMECpairs(), chaninfo::CosmicEff::endJob(), calib::TimingCalFilter::endSubRun(), calib::DCMTimingOffset::endSubRun(), ErrorBand(), ana::ErrorBarChart(), ValidCalibPDF::EssentialComparisonTex(), event_reweighting_all_knobs(), Tier.Tier::executeProcess(), fd_plot(), ana::FileListSource::FileListSource(), raw2daq::RawDigit2DAQHit::FillDAQHits(), calib::StopperThreshold::FillHist(), lem::EventSummary::FillHists(), caf::FillNueEnergyVars(), skim::SkimmerAna::FillNumuHistograms(), skim::CosmicBeamComparison::FillNumuHistograms(), trk::CosmicTrackAna::FillTrackMCTruthHistograms(), calib::StopperThreshold::FillTree(), fnex::NuMuAnalysisSetup::FillVars(), fnex::NuEAnalysisSetup::FillVars(), novaddt::NuMuTrigger::filter(), novaddt::MoonShadow::filter(), novaddt::UpMuTestTrigger::filter(), novaddt::FastMMTrigger::filter(), novaddt::NNFastMMTrigger::filter(), novaddt::SlowMMTrigger::filter(), mono::Cluster::find_max_gap(), novaddt::smt::Trigger::find_max_gap(), mono::SlowMonopoleTrigger::find_max_gap(), ana::GenieMultiverseSpectra::FindBandBoundaries(), novaddt::ContainedSlice::findBoundingBox(), novaddt::NuMuTrigger::findBoundingBox(), FindLimitY(), ViewBokeh::findRange(), hv::HoughVertexAlg::FindVertex(), PandAna.weight.xsec_utils.NuWeightDFWrapper::FindXBin(), PandAna.weight.xsec_utils.NuWeightDFWrapper::FindYBin(), calib::AbsCalib::fitMEU(), FixMCHist(), evdb::Colors::Foreground(), FormatErrorBand(), ana::FormatErrorBand(), FormatFullCovMxPlot(), nuesand::FillNueSandbox::FracModalHits(), geo::LiveGeometry::FullNDProjectedCells(), get_cosmic_sample(), stan::lang::function_signatures::get_result_type(), stan::lang::function_signatures::get_signature_matches(), DrawUtils::GetBestYRange(), GetHistMax(), canMan.Table::getLatex(), GetMaxUpDown(), GetMaxUpDown2D(), ana::SystConcat::GetPosition(), tdslicer::TDSlicer::GetPtInfo(), canMan.Table::getReadable(), ana::GenieMultiverseSpectra::GetSigmaHistograms(), GetSignGraph(), fnex::CorrectedSpectrum::GetStacksCanvasCopy(), getTimePeakPlots(), GoodDataSelDate(), GoodDataSelDuration(), GoodDataSelEmptySpillFrac(), GoodDataSelGoodDB(), GoodDataSelLiveTime(), GoodDataSelMipRate(), GoodDataSelNumSlices(), GoodDataSelRuns(), GoodDataSelTimingPeakEnd(), GoodDataSelTimingPeakStart(), GoodDataSelTrkFrac(), goodness_of_fit(), trk::CosmicTrackSelection::GoodSteps(), calib::PCHitsList::GoodSteps(), handle_event(), ana::Hash(), fnex::NuMuAnalysisSetup::HighestPIDTrack(), remid::HighestPIDTrack(), ana::FitTanSqTheta12::HighLimit(), HandyFuncs::HorizontalRange(), genie::HAIntranuke::Inelastic(), genie::HAIntranuke2018::Inelastic(), art::detail::info_success(), genie::BLI2DUnifGrid::Init(), genie::BLI2DNonUnifGrid::Init(), ana::FCBin::InitFromTree(), mono::DataCheckMonopole::initialize(), cmf::CovarianceFitHelper::InitializeGlobalVars(), geo::InitializePathTable(), fnex::ParameterConstraints::InsertConstraint(), cmf::ParameterConstraints::InsertConstraint(), geo::LiveGeometry::InstrumentedDetBack(), geo::LiveGeometry::InstrumentedDetEnds(), geo::LiveGeometry::InstrumentedDetFront(), geo::LiveGeometry::InstrumentedDetLength(), art::ScheduleID::invalid_id_(), art::RangeSet::invalidChecksum(), art::ModuleDescription::invalidID(), zcl::FastMonopoleTriggers::is_trigger_by_epoch1_fmmtrigger(), trk::CosmicTrackSelection::IsCalibTrack(), nnbar::NNbarUtilities::isContainedSlice(), nnbar::NNbarUtilities::isFebFlasher(), calib::PCHitsList::IsGoodTrack(), geo::LiveGeometry::IsPointLiveInfo(), joint_fit_2017_contours(), joint_fit_2017_fc_submit(), joint_fit_2018_contours(), joint_fit_2019_contours(), jointsensitivity(), skim::SelectionNue2017::KeepNueNearDetectorSlice(), skim::SelectionNue2018RHC::KeepNueNearDetectorSlice(), skim::SelectionNueSA::KeepNueNearDetectorSlice(), skim::SelectionNue2018FHC::KeepNueNearDetectorSlice(), skim::SelectionNumu2017::KeepNumuNearDetectorSlice(), skim::SelectionNumu2018::KeepNumuNearDetectorSlice(), skim::EvaluatorNue::KeepSlice(), PandAna.var.analysis_vars::kMaxY(), ana::kMinPngNhit(), ana::kNue2017BasicPartFunc(), ana::kNue2020FDPeripheralFunc_MRBrem(), ksTest(), photrans::line_efficiency(), nerd::NERDEval::load_truth(), genie::IMDXSec::LoadConfig(), genie::RESXSec::LoadConfig(), genie::DMELXSec::LoadConfig(), genie::DFRXSec::LoadConfig(), genie::NuElectronXSec::LoadConfig(), genie::MECXSec::LoadConfig(), genie::NewQELXSec::LoadConfig(), ana::SingleNucAnalysis::LoadFrom(), ana::NumuCC2p2hAnalysis::LoadFrom(), ana::CrossSectionAnalysis::LoadFrom(), LogClone(), art::TimeTracker::logToDestination_(), make_dst_cosrejbdttrain(), make_muonid_opt(), EmPlot::make_plot(), make_plots(), makeCanvas(), MakeComparisonPlots(), MakeComparisonPlotsWithRatio(), cmf::CovarianceFitHelper::MakeDataMCCanv(), fnex::CovarianceFitHelper::MakeDataMCFitCanvs(), fnex::ContourMaker::MakeDeltaChiSqrMaps(), PandAna.Demos.tute_plots::MakeDeltaCVNPlots(), MakeLegend(), SupernovaUtilities::MakeLogList(), MakeMePlot(), MakeNuEnergyPlots(), MakePlot(), MakePlots(), MakeStackNME(), MakeStackPlot(), MakeSummaryTable(), trk::CosmicTrackAlg::MakeTrack(), makeXSecPlots1D(), makeXSecPlots2D(), MatrixValidation(), std::numeric_limits< stan::math::fvar< T > >::max(), std::numeric_limits< stan::math::var >::max(), novaddt::smt::Track::max_cell(), novaddt::smt::Track::max_plane(), art::debugging_allocator< T >::max_size(), nuesand::FillNueSandbox::MaxGap(), nuesand::FillNueSandbox::MaxHits(), maxID(), ana::MCMCSamples::MaxValue(), dt::Cand::MinMaxLines(), MostConservative(), rb::Cluster::MostContiguousPlanes(), rb::Cluster::MostMissingPlanes(), MoveDeltaToT2KUnits(), multihough_production_validation(), myBarChart(), MyPlotWithSystErrorBand(), novaddt::NuMuTrigger::n3DCellsToEdge(), NDHists(), stan::math::neg_binomial_2_cdf(), stan::math::neg_binomial_cdf(), stan::math::neg_binomial_lccdf(), stan::math::neg_binomial_lcdf(), slicer::PointManager::NeighborScore(), ana::FluxDecomp::NueEstimate(), ana::BENDecomp::NueEstimate(), ana::FluxDecomp::NueEstimateFromKa(), fnex::ShifterAndWeighter::NueExtrapSig2017Weight(), ana::NueRecoE_2017FDFit(), ana::NueRecoE_2018FHCFit(), ana::NueRecoE_2020FHCFit(), zcl::FastMonopoleTriggers::NumberOfHitsInOverlapPlanesCut(), novaddt::FastMMTrigger::NumberOfHitsInOverlapPlanesCut(), novaddt::NNFastMMTrigger::NumberOfHitsInOverlapPlanesCut(), zcl::FmmTriggerEvd::NumberOfHitsInOverlapPlanesCut(), zcl::FastMMStudy::NumberOfHitsInOverlapPlanesCut(), OnMonPlotMaker(), ana::NotContainFxn::operator()(), ana::CutOptimization::OptimizedSigmaOverSigma(), novaddt::HoughTrackMaker::PairCutter(), skim::ParametersNue::ParametersNue(), skim::ParametersNumu::ParametersNumu(), cmf::InputPoint::ParameterValue(), fnex::InputPoint::ParameterValue(), zcl::FastMonopoleTriggers::passed_epoch2_fmmtrigger(), ana::PassesPreselFunc(), ParserDBUsage.DBUsage::peak(), Plot(), Plot1D(), plot_datamcpred(), plot_joint_fit_2020_contours(), plot_timing_resolution(), ana::CutOptimization::PlotDebug(), PlotErrorBand(), ana::PlotErrorBand(), PlotEvents(), ana::PlotMultiSyst(), PlotMultiverse(), PlotNumuPredData(), plotNumuWrongSign(), PlotRat(), cmf::ReadFitResults::plotResults(), fnex::ReadFitResults::plotResults(), PlotSignificanceVsYear_FixDelta(), ana::PlotSpectra(), ana::PlotStack(), PlotStack(), PlotSyst(), ana::PlotSyst(), ana::PlotSystBand(), PlotSystErrorBand(), PlotSysts(), Plotting_DataAndPrediction(), ana::PlotWithSystErrorBand(), ana::PlotWithSystErrorBand_Quant(), plotWrongSignFraction(), stan::math::poisson_cdf(), stan::math::poisson_lccdf(), stan::math::poisson_lcdf(), pred_err(), tdslicer::TDSlicer::Prims(), print_tables(), HandyFuncs::PrintError(), HandyFuncs::printlist(), plot_xsec_2d::process_focusing(), plot_xsec_2d::process_light_calibration_mue(), plot_xsec_2d::process_multiuniverse(), genie::RESKinematicsGenerator::ProcessEventRecord(), MergeDaqCollections::MergeDaqCollections::produce(), slid::Recluster::produce(), jmshower::JMTrackMerge::produce(), calib::FiberCalibration::produce(), cosrej::CosRej::produce(), zcl::FMMTracker::produce(), zcl::FmmTriggerEvd::produce(), slid::LIDBuilder::produce(), jmshower::NueSel::produce(), cosrej::MakeNueCosRej::produce(), caf::CAFMaker::produce(), skim::ParametersNumu::ProjectDistToEdge(), geo::LiveGeometry::ProjectedDistance(), RatioPlot(), ana::RatioPlot(), cmf::CombineResults::readResults(), fnex::ContourMaker::readResults(), cmf::StarPlot::readResults(), fnex::StarPlot::readResults(), cmf::ContourMaker::readResults(), calib::AttenuationFit::readResults(), fnex::NuEAnalysisSetup::Reconfigure(), jmshower::RecoJMShower::RecoShowers(), ana::UnfoldTikhonov::RecoTruthPrediction(), reduce_numu_ana2017_prod(), stan::optimization::BFGSMinimizer< ModelAdaptor< M >, QNUpdateType, Scalar, DimAtCompile >::rel_grad_norm(), stan::optimization::BFGSMinimizer< ModelAdaptor< M >, QNUpdateType, Scalar, DimAtCompile >::rel_obj_decrease(), remakeresultsplots_nue(), request_edarea_size(), art::Defaults::seconds_max(), selection_story_plots(), genie::MECGenerator::SelectNSVLeptonKinematics(), sensitivity2018(), sensitivity2020(), SetBinsOnOffShift(), SetBinsPlusMinusOne(), genie::flux::GAstroFlux::SetEnergyPowLawIdx(), evdb::ParameterSetEditRow::SetupSlider(), ana::GeniePCASyst::Shift(), ana::SummedSyst::Shift(), ana::RelMuEScaleSyst2017::Shift(), ana::BolombMuESyst2019::Shift(), ana::PredictionInterp::ShiftBins(), SignalCountPlot(), novaddt::DDTTrackMerge::simpleMerge(), novaddt::Merge2DTracks::simpleMerge(), slicer_production_validation(), lem::LEMSummarizer::SliceToLEMInput(), ana::sort_chisq_bkg(), ana::sort_chisq_sig(), ana::sort_chisq_tot(), start_freerun_timer(), stan::variational::advi< stan_model, stan::variational::normal_meanfield, rng_t >::stochastic_gradient_ascent(), syst_test(), systematics_extrap_comp_from_pred_interp(), systematics_summary_from_pred_interp(), fnex::ShifterAndWeighter::TauScaleSystWeight(), cmf::ShifterAndWeighter::TauScaleSystWeight(), TEST(), test_genieweights(), test_stanfit_withsysts(), testfom(), Projections::tierEfficiency(), mono::Track3D::time_gap(), rb::Prong::TotalLength(), dt::Chain::ToTrack(), ana::CutOptimization::ToUpDownHist(), mono::Track::Track(), trimmubarid(), trimvar(), ana::BeamSyst::TruthShift(), dt::Cand::TryAddSeg(), Tutorial2019FitContours(), novaddt::Merge2DTracks::twoViewMerge(), art::Defaults::unsigned_max(), progbar.ProgressBar::Update(), genie::supernova::Limits< double >::UpdateMax(), validation(), slid::NuEEnergyAlg::VertexEnergy(), dt::View::View(), zcl::FastMonopoleTriggers::WeightedCenterCut(), novaddt::FastMMTrigger::WeightedCenterCut(), novaddt::NNFastMMTrigger::WeightedCenterCut(), zcl::FastMMStudy::WeightedCenterCut(), ana::Nus17SystFromHist::WeightFor(), ana::NusSystFromHist::WeightFor(), ana::Nus18SystFromHist::WeightFor(), ana::NusISyst::WeightFor(), stan::math::wiener_lpdf(), and stan::optimization::WolfLSZoom().

71 {
72  query_result<T> r;
73  r << select("max(" + column_name + ")").from(db, table_name);
74  return unique_value(r);
75 }
T unique_value(query_result< T > const &r)
Definition: query_result.h:101
auto select(T const &...t)
Definition: select.h:155
TRandom3 r(0)
double cet::sqlite::mean ( sqlite3 *  db,
std::string const &  table_name,
std::string const &  column_name 
)
double cet::sqlite::median ( sqlite3 *  db,
std::string const &  table_name,
std::string const &  column_name 
)
template<typename T = double>
T cet::sqlite::min ( sqlite3 *const  db,
std::string const &  table_name,
std::string const &  column_name 
)

Definition at line 57 of file statistics.h.

References r(), select(), T, and unique_value().

60 {
61  query_result<T> r;
62  r << select("min(" + column_name + ")").from(db, table_name);
63  return unique_value(r);
64 }
T unique_value(query_result< T > const &r)
Definition: query_result.h:101
auto select(T const &...t)
Definition: select.h:155
TRandom3 r(0)
unsigned cet::sqlite::nrows ( sqlite3 *  db,
std::string const &  tablename 
)
template<typename... Args>
std::ostream& cet::sqlite::operator<< ( std::ostream &  os,
query_result< Args... > const &  res 
)

Definition at line 112 of file query_result.h.

References cet::sqlite::query_result< Args >::columns, cet::sqlite::query_result< Args >::data, MECModelEnuComparisons::i, and check_grl::row.

113  {
114  using size_t = decltype(res.columns.size());
115  auto const ncolumns = res.columns.size();
116  for (size_t i{}; i != ncolumns; ++i) {
117  os << res.columns[i] << ' ';
118  }
119  os << "\n--------------------------------\n";
120  for (auto const& row : res.data) {
121  // os << row.str() << '\n';
122  }
123  return os;
124  }
template<typename... Args>
void cet::sqlite::operator<< ( query_result< Args... > &  r,
SelectStmt const &  cq 
)

Definition at line 171 of file select.h.

References cet::sqlite::SelectStmt::db_, cet::sqlite::SelectStmt::ddl_, and query().

172  {
173  r = query<Args...>(cq.db_, cq.ddl_ + ";");
174  }
TRandom3 r(0)
query_result< Args... > query(sqlite3 *db, std::string const &ddl)
Definition: select.h:76
template<typename... Args>
query_result<Args...> cet::sqlite::query ( sqlite3 *  db,
std::string const &  ddl 
)

Definition at line 76 of file select.h.

References cet::sqlite::detail::get_result(), lem_server::msg, and cet::sqlite::errors::SQLExecutionError.

Referenced by operator<<().

77  {
78  query_result<Args...> res;
79  char* errmsg{nullptr};
80  if (sqlite3_exec(
81  db, ddl.c_str(), detail::get_result<Args...>, &res, &errmsg) !=
82  SQLITE_OK) {
83  std::string msg{errmsg};
84  sqlite3_free(errmsg);
86  }
87  return res;
88  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
int get_result(void *data, int ncols, char **results, char **cnames)
Definition: get_result.h:36
double cet::sqlite::rms ( sqlite3 *  db,
std::string const &  table_name,
std::string const &  column_name 
)
template<typename... T>
auto cet::sqlite::select ( T const &...  t)

Definition at line 155 of file select.h.

References cet::sqlite::detail::concatenate(), fillBadChanDBTables::result, and T.

Referenced by max(), min(), art::TimeTracker::postEndJob(), and art::MemoryTracker::summary_().

156  {
157  std::string result{"select " + detail::concatenate(t...)};
158  return IncompleteSelectStmt{std::move(result)};
159  }
std::string concatenate(H const &h, T const &...t)
Definition: select.h:146
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
template<typename... T>
auto cet::sqlite::select_distinct ( T const &...  t)

Definition at line 163 of file select.h.

References cet::sqlite::detail::concatenate(), and fillBadChanDBTables::result.

Referenced by art::TimeTracker::postEndJob().

164  {
165  std::string result{"select distinct " + detail::concatenate(t...)};
166  return IncompleteSelectStmt{std::move(result)};
167  }
std::string concatenate(H const &h, T const &...t)
Definition: select.h:146
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
template<typename T >
T cet::sqlite::unique_value ( query_result< T > const &  r)
inline

Definition at line 101 of file query_result.h.

References cet::sqlite::query_result< Args >::data, and cet::sqlite::errors::SQLExecutionError.

Referenced by max(), min(), art::TimeTracker::postEndJob(), and art::MemoryTracker::summary_().

102  {
103  if (r.data.size() != 1ull) {
105  << "unique_value expected of non-unique query.";
106  }
107  return std::get<T>(r.data[0]);
108  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
TRandom3 r(0)