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