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.
void sqlselect()
{
printf(
"Server info: %s\n",
db->ServerInfo());
printf(
"\nList all databases on server %s\n",
db->GetHost());
res =
db->GetDataBases();
while ((row = res->
Next())) {
delete row;
}
delete res;
printf(
"\nList all tables in database \"test\" on server %s\n",
res =
db->GetTables(
"test");
while ((row = res->
Next())) {
delete row;
}
delete res;
printf(
"\nList all columns in table \"runcatalog\" in database \"test\" on server %s\n",
res =
db->GetColumns(
"test",
"runcatalog");
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)";
for (
int i = 0; i <
nfields*40; i++)
for (
int i = 0; i <
nrows; i++) {
}
delete row;
}
delete res;
}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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
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....
- Author
- Sergey Linev, Juan Fernando Jaramillo Botero
Definition in file sqlselect.C.