@GrabConfig(systemClassLoader = true) @Grab('mysql:mysql-connector-java:5.1.31') import groovy.sql.Sql def db = Sql.newInstance("jdbc:mysql://localhost:3306/dbname", "root", "", "com.mysql.jdbc.Driver") db.eachRow('show tables') { row -> def tableName = row[0] db.eachRow("select count(*) as cnt from " + tableName) { println "$tableName: $it.cnt" } }