ROOT
6.30.04
Reference Guide
All
Namespaces
Files
Pages
sqlcreatedb.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_sql
3
/// Create a runcatalog table in a MySQL test database.
4
///
5
/// \macro_code
6
///
7
/// \author Sergey Linev
8
9
void
sqlcreatedb()
10
{
11
// read in runcatalog table definition
12
FILE *fp = fopen(
"runcatalog.sql"
,
"r"
);
13
const
char
sql[4096];
14
fread(sql, 1, 4096, fp);
15
fclose(fp);
16
17
// open connection to MySQL server on localhost
18
TSQLServer *db = TSQLServer::Connect(
"mysql://localhost/test"
,
"nobody"
,
""
);
19
20
TSQLResult *res;
21
22
// create new table (delete old one first if exists)
23
res = db->Query(
"DROP TABLE runcatalog"
);
24
delete
res;
25
26
res = db->Query(sql);
27
delete
res;
28
29
delete
db;
30
}
tutorials
sql
sqlcreatedb.C
Generated on Tue May 5 2020 14:03:50 for ROOT by
1.8.5