@@ -0,0 +1,2038 @@
+## %5Cfile%0A## %5Cingroup tutorial_sql%0A## Query example to MySQL test database.%0A## Example of query by using the test database made in MySQL, you need the%0A## database test installed in localhost, with user nobody without password.%0A##%0A## Based on sqlselect.C by Sergey Linev%0A##%0A## %5Cmacro_code%0A##%0A## %5Cauthor Juan Fernando Jaramillo Botero%0A%0Afrom ROOT import TSQLServer, TSQLResult, TSQLRow, TStopwatch%0A%0A%0Adb = TSQLServer.Connect(%22mysql://localhost/test%22, %22nobody%22, %22%22)%0A%0Aprint(%22Server info: %25s%22 %25 db.ServerInfo())%0A%0A# list databases available on server%0Aprint%0Aprint %22List all databases on server %25s%22 %25 db.GetHost()%0Ares = db.GetDataBases()%0Arow = res.Next()%0Awhile row:%0A    print(%22%25s%22 %25 row.GetField(0))%0A    row = res.Next()%0A%0A# list tables in database %22test%22 (the permission tables)%0Aprint%0Aprint('List all tables in database %22test%22 on server %25s' %25 db.GetHost())%0Ares = db.GetTables(%22test%22)%0Arow = res.Next()%0Awhile row:%0A    print(%22%25s%22 %25 row.GetField(0))%0A    row = res.Next()%0A%0A# list columns in table %22runcatalog%22 in database %22mysql%22%0Aprint%0Aprint('List all columns in table %22runcatalog%22 in database %22test%22 on server %25s' %25%0A      db.GetHost())%0Ares = db.GetColumns(%22test%22, %22runcatalog%22)%0Arow = res.Next()%0Awhile row:%0A    print(%22%25s%22 %25 row.GetField(0))%0A    row = res.Next()%0A%0A# start timer%0Atimer = TStopwatch()%0Atimer.Start()%0A%0A# query database and print results%0A# sql = %22select dataset,rawfilepath from test.runcatalog %22 %5C%0A#       %22WHERE tag&(1%3C%3C2) AND (run=490001 OR run=300122)%22%0Asql = %22select count(*) from test.runcatalog %22 %5C%0A      %22WHERE tag&(1%3C%3C2)%22%0A%0Ares = db.Query(sql)%0A%0Anrows = res.GetRowCount()%0Aprint%0Aprint(%22Got %25d rows in result%22 %25 nrows)%0A%0Anfields = res.GetFieldCount()%0Afor i in range(nfields):%0A  print(%22%2540s%22 %25 res.GetFieldName(i))%0Aprint%0Aprint(%22=%22*(nfields*40))%0Aprint%0A%0Afor i in range(nrows):%0A    row = res.Next()%0A    for j in range(nfields):%0A        print(%22%2540s%22 %25 row.GetField(j))%0A    print%0A%0A# stop timer and print results%0Atimer.Stop()%0Artime = timer.RealTime()%0Actime = timer.CpuTime()%0A%0Aprint%0Aprint(%22RealTime=%25f seconds, CpuTime=%25f seconds%22 %25 (rtime, ctime))%0A

Add translate sqlselect.C to python