Query example to MySQL test database.
Example of query by using the test database made in MySQL, you need the database test installed in localhost, with user nobody without password.
{
printf(
"\nList all databases on server %s\n", db->
GetHost());
while ((row = res->
Next())) {
delete row;
}
delete res;
printf("\nList all tables in database \"test\" on server %s\n",
while ((row = res->
Next())) {
delete row;
}
delete res;
printf("\nList all columns in table \"runcatalog\" in database \"test\" on server %s\n",
while ((row = res->
Next())) {
delete row;
}
delete res;
const char *sql = "select dataset,rawfilepath from test.runcatalog "
"WHERE tag&(1<<2) AND (run=490001 OR run=300122)";
printf("\nGot %d rows in result\n", nrows);
for (int i = 0; i < nfields; i++)
printf("\n");
for (int i = 0; i < nfields*40; i++)
printf("=");
printf("\n");
for (int i = 0; i < nrows; i++) {
for (int j = 0; j < nfields; j++) {
}
printf("\n");
delete row;
}
delete res;
delete db;
printf("\nRealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime);
}
virtual const char * GetFieldName(Int_t field)=0
virtual Int_t GetRowCount() const
virtual TSQLRow * Next()=0
virtual Int_t GetFieldCount()=0
virtual const char * GetField(Int_t field)=0
const char * GetHost() const
virtual const char * ServerInfo()=0
virtual TSQLResult * Query(const char *sql)=0
virtual TSQLResult * GetTables(const char *dbname, const char *wild=0)=0
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.
virtual TSQLResult * GetDataBases(const char *wild=0)=0
virtual TSQLResult * GetColumns(const char *dbname, const char *table, const char *wild=0)=0
Double_t RealTime()
Stop the stopwatch (if it is running) and return the realtime (in seconds) passed between the start a...
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
Double_t CpuTime()
Stop the stopwatch (if it is running) and return the cputime (in seconds) passed between the start an...
void Stop()
Stop the stopwatch.