14from ROOT
import TSQLServer, TSQLResult, TSQLRow, TStopwatch
19print(
"Server info: %s" % db.ServerInfo())
23print(
"List all databases on server %s" % db.GetHost())
24res = db.GetDataBases()
27 print(
"%s" % row.GetField(0))
32print(
'List all tables in database "test" on server %s' % db.GetHost())
33res = db.GetTables(
"test")
36 print(
"%s" % row.GetField(0))
41print(
'List all columns in table "runcatalog" in database "test" on server %s' %
43res = db.GetColumns(
"test",
"runcatalog")
46 print(
"%s" % row.GetField(0))
56sql =
"select count(*) from test.runcatalog " \
61nrows = res.GetRowCount()
63print(
"Got %d rows in result" % nrows)
65nfields = res.GetFieldCount()
66for i
in range(nfields):
67 print(
"%40s" % res.GetFieldName(i))
69print(
"=" * (nfields * 40))
74 for j
in range(nfields):
75 print(
"%40s" % row.GetField(j))
80rtime = timer.RealTime()
81ctime = timer.CpuTime()
84print(
"RealTime=%f seconds, CpuTime=%f seconds" % (rtime, ctime))
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....