DatabaseInterface

Contents

Contact Name

Nick West.

Overview

This package provides the standard interface to the database. Its primary service is to satisfy the request:-

"For this event give me all the data of that type which is valid"

It takes a VldContext and collects all rows from the required database table which are valid for that context i.e. date, detector type, and data type (e.g real or MC).

User Interface

The main interface object is the DbiResultPtr. It is templated on the type of row held in the required database table. Its constructor is given a VldContext from which to get the context that the database rows must match.

In the following code fragment a CandHandle cdlh is used to determine the context to create a DbiResultPtr for table Xxx. This generates the query, unless the result is already in the internal cache. The code then loops over each row of valid data.


DbiResultPtr<Xxx> myResPtr(cdlh.GetVldContext());

for ( UInt_t irow = 0; irow < myResPtr.GetNumRows(); ++irow) {
  const Xxx* row = myResPtr.GetRow(irow);

// Process row.

}
See also DatabaseInterface Overview

Database Access

The interface can only access certain types of database table, those in which there is both a main table, holding the data itself, and an auxiliary validity table, whose name is formed by adding the suffix VLD to the table name, that contains the validity information.

Configuring & Running

There are two types of configuration: Environmental Variables and Job Macro code.

Environmental Variables

The databases that the interface will interrogate and the accounts it will use are defined by 3 environmental variables. Here is an example setting of them

setenv ENV_TSQL_URL "mysql:odbc://pplx2.physics.ox.ac.uk/offline"
setenv ENV_TSQL_USER "..."
setenv ENV_TSQL_PSWD "..."

Job Macro Code

To configure, first a DbiTableProxyRegistry is obtained from the static Instance() method, the Set() method used as required and finnally the Update() method applies them.

   // DbiTableProxyRegistry is a CfgConfigurable 
   DbiTableProxyRegistry& dbiCfg = DbiTableProxyRegistry::Instance();
   dbiCfg.Set("...");
   dbiCfg.Set("...");
   dbiCfg.Set("...");
   dbiCfg.Update();
The following are configurable:-

Further Links


Nick West Last Modified: $Date: 2004/10/13 12:04:03 $