HARPO  5.1.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
harpodbquery.cxx
Go to the documentation of this file.
1 //
2 // Demo code for harpo database arbitry query
3 //
4 
5 #include "HarpoDB.h"
6 #include "TString.h"
7 #include <iostream>
8 #include <stdlib.h>
9 #include <unistd.h>
10 
11 
12 int main(int /* argc*/ , char ** /* argv */)
13 {
14  HarpoDB *db;
15 
16  db = new HarpoDB;
17  db->Open();
18 
20 
21  if (db->ExecQuery("SELECT * FROM qq;"))
22  std::cout << "Query Ok." << std::endl;
23  else
24  std::cout << "Bad SELET QUERY" << std::endl;
25 
27 
28  dbResults run_list;
29 
30  if (db->ExecQuery("SELECT `run`,`IwLaser` FROM `NSBeam` WHERE `Palarisation` = 100;",&run_list) ) {
31  // std::cout << "Ok, size of rsult " << run_list.size() << std::endl;
32  } else
33  std::cout << "Bad SELET QUERY" << std::endl;
34 
35  for(dbResults::iterator il=run_list.begin();il !=run_list.end();++il){
36  std::cout << " ======================" << std::endl;
37  for(dbFields::iterator im=il->begin();im != il->end();++im){
38  std::cout << im->first << " = " << im->second << std::endl;
39  }
40  }
41  db->Close();
42  delete db;
43  return 0;
44 }
45 
46 
47 
Bool_t Open(const TString *DbUrl=NULL)
Definition: HarpoDB.cxx:77
std::list< dbFields > dbResults
Definition: HarpoDB.h:21
Harpo Database access class. The class query MySQL database. Deal with (single !) Harpo Database and ...
Definition: HarpoDB.h:112
int main(int, char **)
Bool_t ExecQuery(const TString sql, dbResults *list=NULL)
Definition: HarpoDB.cxx:170
Bool_t Close()
Definition: HarpoDB.cxx:111